GNU bug report logs - #78546
[PATCH 0/3] Add iwd-service-type.

Previous Next

Package: guix-patches;

Reported by: Sergey Trofimov <sarg <at> sarg.org.ru>

Date: Thu, 22 May 2025 11:26:02 UTC

Severity: normal

Tags: patch

Done: Sergey Trofimov <sarg <at> sarg.org.ru>

To reply to this bug, email your comments to 78546 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Thu, 22 May 2025 11:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sergey Trofimov <sarg <at> sarg.org.ru>:
New bug report received and forwarded. Copy sent to gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org. (Thu, 22 May 2025 11:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: guix-patches <at> gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 0/3] Add iwd-service-type.
Date: Thu, 22 May 2025 13:24:51 +0200
This series adds a shepherd service for IWD.
Resolves https://issues.guix.gnu.org/59971

Sergey Trofimov (3):
  services: configuration: Add define-enumerated-field-type helper.
  services: networking: Add shepherd-requirement for dhcpcd.
  services: networking: Add iwd-service-type.

 doc/guix.texi                  | 166 +++++++++++++++++++-
 gnu/services/configuration.scm |  13 ++
 gnu/services/cups.scm          |  12 --
 gnu/services/networking.scm    | 268 +++++++++++++++++++++++++++++++--
 gnu/services/power.scm         |  45 ++----
 gnu/services/vpn.scm           |  12 --
 6 files changed, 443 insertions(+), 73 deletions(-)


base-commit: ed83953921cd3a2abb09c1709399053c092215a2
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Thu, 22 May 2025 11:35:01 GMT) Full text and rfc822 format available.

Message #8 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 1/3] services: configuration: Add define-enumerated-field-type
 helper.
Date: Thu, 22 May 2025 13:32:55 +0200
* gnu/services/cups.scm (define-enumerated-field-type): Move...
* gnu/services/configuration.scm (define-enumerated-field-type): ...here.
* gnu/services/vpn.scm (define-enumerated-field-type): Remove.
* gnu/services/power.scm
(define-enum): Replace with define-enumerated-field-type.

Change-Id: I89ec40f479e3f800268e714f1f88d638be017c7e
---
 gnu/services/configuration.scm | 13 ++++++++++
 gnu/services/cups.scm          | 12 ---------
 gnu/services/power.scm         | 45 +++++++++++-----------------------
 gnu/services/vpn.scm           | 12 ---------
 4 files changed, 27 insertions(+), 55 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 15eddd7665..659a25f352 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -75,6 +75,7 @@ (define-module (gnu services configuration)
             configuration->documentation
             empty-serializer
             serialize-package
+            define-enumerated-field-type
 
             filter-configuration-fields
 
@@ -508,6 +509,18 @@ (define* (interpose ls  #:optional (delimiter "\n") (grammar 'infix))
                           (cons delimiter acc))))
               '() ls))
 
+(define-syntax define-enumerated-field-type
+  (lambda (x)
+    (define (id-append ctx . parts)
+      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
+    (syntax-case x ()
+      ((_ name (option ...))
+       #`(begin
+           (define (#,(id-append #'name #'name #'?) x)
+             (memq x '(option ...)))
+           (define (#,(id-append #'name #'serialize- #'name) field-name val)
+             (serialize-field field-name val)))))))
+
 
 ;;;
 ;;; Commonly used predicates
diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index 738bb7f5cc..27aac7a16a 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -137,18 +137,6 @@ (define (non-negative-integer? val)
 (define (serialize-non-negative-integer field-name val)
   (serialize-field field-name val))
 
-(define-syntax define-enumerated-field-type
-  (lambda (x)
-    (define (id-append ctx . parts)
-      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
-    (syntax-case x ()
-      ((_ name (option ...))
-       #`(begin
-           (define (#,(id-append #'name #'name #'?) x)
-             (memq x '(option ...)))
-           (define (#,(id-append #'name #'serialize- #'name) field-name val)
-             (serialize-field field-name val)))))))
-
 (define-enumerated-field-type access-log-level
   (config actions all))
 (define-enumerated-field-type browse-local-protocols
diff --git a/gnu/services/power.scm b/gnu/services/power.scm
index ec8ae555d4..ad386549cd 100644
--- a/gnu/services/power.scm
+++ b/gnu/services/power.scm
@@ -204,23 +204,6 @@ (define-configuration/no-serialization apcupsd-event-handlers
     #~(#t))
    "The handler for the battattach event."))
 
-(define-syntax define-enum
-  (lambda (x)
-    (syntax-case x ()
-      ((_ name values)
-       (let* ((datum/name (syntax->datum #'name))
-              (datum/predicate (string->symbol
-                                (format #f "enum-~a?" datum/name)))
-              (datum/serialize (string->symbol
-                                (format #f "serialize-enum-~a" datum/name))))
-         (with-syntax
-             ((predicate (datum->syntax x datum/predicate))
-              (serialize (datum->syntax x datum/serialize)))
-           #'(begin
-               (define (predicate value)
-                 (memq value values))
-               (define serialize serialize-symbol))))))))
-
 (define mangle-field-name
   (match-lambda
     ('name                            "UPSNAME")
@@ -252,25 +235,25 @@ (define mangle-field-name
     ('data-time                       "DATATIME")
     ('facility                        "FACILITY")))
 
-(define (serialize-string field-name value)
+(define (serialize-field field-name value)
   #~(format #f "~a ~a\n" #$(mangle-field-name field-name) '#$value))
-(define serialize-symbol serialize-string)
-(define serialize-integer serialize-string)
+(define serialize-string serialize-field)
+(define serialize-symbol serialize-field)
+(define serialize-integer serialize-field)
 (define (serialize-boolean field-name value)
-  #~(format #f "~a ~a\n"
-            #$(mangle-field-name field-name)
-            #$(if value "on" "off")))
+  (serialize-field field-name (if value "on" "off")))
 
 (define-maybe string)
 
-(define-enum cable '( simple smart ether usb
-                      940-0119A 940-0127A 940-0128A 940-0020B 940-0020C
-                      940-0023A 940-0024B 940-0024C 940-1524C 940-0024G
-                      940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000))
-(define-enum type '(apcsmart usb net snmp netsnmp dumb pcnet modbus test))
-(define-enum no-logon '(disable timeout percent minutes always))
-(define-enum class '(standalone shareslave sharemaster))
-(define-enum mode '(disable share))
+(define-enumerated-field-type enum-cable
+   ( simple smart ether usb
+     940-0119A 940-0127A 940-0128A 940-0020B 940-0020C
+     940-0023A 940-0024B 940-0024C 940-1524C 940-0024G
+     940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000))
+(define-enumerated-field-type enum-type (apcsmart usb net snmp netsnmp dumb pcnet modbus test))
+(define-enumerated-field-type enum-no-logon (disable timeout percent minutes always))
+(define-enumerated-field-type enum-class (standalone shareslave sharemaster))
+(define-enumerated-field-type enum-mode (disable share))
 
 (define-configuration apcupsd-configuration
   (apcupsd (package apcupsd) "The @code{apcupsd} package to use.")
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index f97cbac7bb..56022ac27a 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -141,18 +141,6 @@ (define (ip-mask? val)
            #f)))
 (define serialize-ip-mask serialize-string)
 
-(define-syntax define-enumerated-field-type
-  (lambda (x)
-    (define (id-append ctx . parts)
-      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
-    (syntax-case x ()
-      ((_ name (option ...))
-       #`(begin
-           (define (#,(id-append #'name #'name #'?) x)
-             (memq x '(option ...)))
-           (define (#,(id-append #'name #'serialize- #'name) field-name val)
-             (serialize-field field-name val)))))))
-
 (define-enumerated-field-type proto
   (udp tcp udp6 tcp6))
 (define-enumerated-field-type dev

base-commit: ed83953921cd3a2abb09c1709399053c092215a2
prerequisite-patch-id: f9cc903b8048c8c6fde576fbf38ab110263020e3
prerequisite-patch-id: b6d30068ce4971d4d8e67517229916df4e76c529
prerequisite-patch-id: c99e71b3eaa726b8ecf2d9b782d5a6a51476e702
prerequisite-patch-id: 08fa3e98a432063db118aa1502c6bd0166415bdd
prerequisite-patch-id: 95bb686bc7dc0961b89a2900a368f270de065d94
prerequisite-patch-id: f56033bf148a2fdfb5d9321315bdff877ebdb7ba
prerequisite-patch-id: 6d43f84387c6ec611389d6f16c1809cc28a29365
prerequisite-patch-id: 73fabf1570be45886923df86ca4c66e4330c3752
prerequisite-patch-id: 2ed8951b99f17bac7694d7e2c3ed0440e650b0c1
prerequisite-patch-id: 09df1d4083ee7abc4f2f346f8576be31db4d193d
prerequisite-patch-id: bace844ae66e50873074acf659ea8fc33796ac73
prerequisite-patch-id: 58f741d217a355489de150faf91cfa5e111d21b5
prerequisite-patch-id: f7817220252740d4dd3433fa2f689f261b82ae6c
prerequisite-patch-id: 8d312fa060e7f6a2b1d58d40c4ff6dc9f1a529a1
prerequisite-patch-id: 38a9fa9641ee1ec252c7068e1b5f9c1ac3a3281c
prerequisite-patch-id: 500be64418ed5e4994de42cfd99b6c8f15498f9d
-- 
2.49.0





Information forwarded to gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Thu, 22 May 2025 11:35:02 GMT) Full text and rfc822 format available.

Message #11 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 2/3] services: networking: Add shepherd-requirement for dhcpcd.
Date: Thu, 22 May 2025 13:32:56 +0200
* gnu/services/networking.scm (dhcpcd-configuration): Add
shepherd-requirement field.
(dhcpcd-shepherd-service): Use it.
* doc/guix.texi (Networking Setup): Regenerate dhcpcd-configuration
documentation.
(File Systems): Fix typo.

Change-Id: Id347e2bed2569237685a47be82dbf686640db25b
---
 doc/guix.texi               | 17 +++++++++++------
 gnu/services/networking.scm | 31 +++++++++++++++++++------------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 02f472246a..3ef2e50e57 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18332,7 +18332,7 @@ File Systems
 might not be sufficient as @code{networking} being marked as started
 does @emph{not} imply the network has already been configured and in
 working order (for example, when using
-@code{dhcpcd-client-service-type}).  For such cases, adding a
+@code{dhcp-client-service-type}).  For such cases, adding a
 requirement on a custom @code{network-online} service may be necessary.
 A sample @code{network-online} one-shot Shepherd service implementation
 is provided below:
@@ -21980,12 +21980,13 @@ Networking Setup
 @item @code{duid} (default: @code{""}) (type: maybe-string)
 DHCPv4 clients require a unique client identifier, this option uses the
 DHCPv6 Unique Identifier as a DHCPv4 client identifier as well.  For
-more information, refer to @uref{https://www.rfc-editor.org/rfc/rfc4361, RFC 4361}
-and @code{dhcpcd.conf(5)}.
+more information, refer to
+@uref{https://www.rfc-editor.org/rfc/rfc4361,RFC 4361} and
+@code{dhcpcd.conf(5)}.
 
 @item @code{persistent?} (default: @code{#t}) (type: boolean)
-When true, automatically de-configure the interface when @command{dhcpcd}
-exits.
+When true, automatically de-configure the interface when
+@command{dhcpcd} exits.
 
 @item @code{option} (default: @code{("rapid_commit" "domain_name_servers" "domain_name" "domain_search" "host_name" "classless_static_routes" "interface_mtu")}) (type: list-of-strings)
 List of options to request from the server.
@@ -22019,9 +22020,13 @@ Networking Setup
 @item @code{extra-content} (type: maybe-string)
 Extra content to append to the configuration as-is.
 
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+This is a list of symbols naming Shepherd services that this service
+will depend on.
+
 @end table
-@end deftp
 
+@end deftp
 
 @cindex NetworkManager
 
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 67653e2cbf..4cb7313808 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -126,6 +126,7 @@ (define-module (gnu services networking)
             dhcpcd-configuration-vendor-class-id
             dhcpcd-configuration-client-id
             dhcpcd-configuration-extra-content
+            dhcpcd-configuration-shepherd-requirement
 
             ntp-configuration
             ntp-configuration?
@@ -609,6 +610,12 @@ (define-configuration dhcpcd-configuration
     maybe-string
     "Extra content to append to the configuration as-is.")
 
+  (shepherd-requirement
+   (list-of-symbols '())
+   "This is a list of symbols naming Shepherd services that this service
+will depend on."
+   empty-serializer)
+
   (prefix dhcpcd-))
 
 (define (dhcpcd-config-file config)
@@ -628,19 +635,19 @@ (define dhcpcd-account-service
           (shell (file-append shadow "/sbin/nologin")))))
 
 (define (dhcpcd-shepherd-service config)
-  (let* ((config-file (dhcpcd-config-file config))
-         (command-args (dhcpcd-configuration-command-arguments config))
-         (ifaces (dhcpcd-configuration-interfaces config)))
-    (list (shepherd-service
-            (documentation "dhcpcd daemon.")
-            (provision '(networking))
-            (requirement '(user-processes udev))
-            (actions (list (shepherd-configuration-action config-file)))
-            (start
+  (match-record config <dhcpcd-configuration>
+                (command-arguments interfaces shepherd-requirement)
+    (let ((config-file (dhcpcd-config-file config)))
+      (list (shepherd-service
+             (documentation "dhcpcd daemon.")
+             (provision '(networking))
+             (requirement `(user-processes udev ,@shepherd-requirement))
+             (actions (list (shepherd-configuration-action config-file)))
+             (start
               #~(make-forkexec-constructor
-                    (list (string-append #$dhcpcd "/sbin/dhcpcd")
-                          #$@command-args "-B" "-f" #$config-file #$@ifaces)))
-            (stop #~(make-kill-destructor))))))
+                 (list (string-append #$dhcpcd "/sbin/dhcpcd")
+                       #$@command-arguments "-B" "-f" #$config-file #$@interfaces)))
+             (stop #~(make-kill-destructor)))))))
 
 (define dhcpcd-service-type
   (service-type (name 'dhcpcd)
-- 
2.49.0





Information forwarded to gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Thu, 22 May 2025 11:35:02 GMT) Full text and rfc822 format available.

Message #14 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 3/3] services: networking: Add iwd-service-type.
Date: Thu, 22 May 2025 13:32:57 +0200
* gnu/services/networking.scm (iwd-service-type): New service type.
(iwd-configuration), (iwd-settings), (iwd-scan-settings),
(iwd-general-settings), (iwd-network-settings): New configuration types.
* doc/guix.texi (Networking setup): Document it.

Change-Id: I852115b9c6768b3ec4eedb34a7f9e66438bd1429
---
 doc/guix.texi               | 157 ++++++++++++++++++++++++
 gnu/services/networking.scm | 237 ++++++++++++++++++++++++++++++++++++
 2 files changed, 394 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3ef2e50e57..e02dda7d9a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22404,6 +22404,163 @@ Networking Setup
 @end table
 @end deftp
 
+@cindex IWD
+@defvar iwd-service-type
+This is the service type to run @acronyml{IWD,Internet Wireless Daemon},
+a wireless daemon required to authenticate against encrypted WiFi
+networks.
+@end defvar
+
+@quotation Warning
+By default @code{iwd} removes and re-creates interfaces it manages.  It
+doesn't play nicely with @code{dhcp-client-service-type} that enumerates
+wireless interfaces before starting the Shepherd service.  Use either
+@code{dhcpcd-service-type} or the @code{iwd}'s built-in DHCP client (see
+@code{enable-network-configuration} option below).
+@end quotation
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-configuration
+Available @code{iwd-configuration} fields are:
+
+@table @asis
+@item @code{iwd} (default: @code{iwd}) (type: file-like)
+The IWD package to use.
+
+@item @code{interfaces} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will control.
+
+@item @code{ignored-interfaces} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will not manage.
+
+@item @code{phys} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will control.
+
+@item @code{ignored-phys} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will not manage.
+
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+Shepherd requirements the service should depend on.
+
+@item @code{shepherd-provision} (default: @code{(iwd)}) (type: list-of-symbols)
+The name(s) of the service.
+
+@item @code{config} (type: iwd-settings)
+Configuration settings.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-settings
+Available @code{iwd-settings} fields are:
+
+@table @asis
+@item @code{general} (type: iwd-general-settings)
+General settings.
+
+@item @code{network} (type: maybe-iwd-network-settings)
+Network settings.
+
+@item @code{scan} (type: maybe-iwd-scan-settings)
+Scan settings.
+
+@item @code{extra-config} (default: @code{()}) (type: list-of-strings)
+Extra configuration values to append to the IWD configuration file.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-general-settings
+Available @code{iwd-general-settings} fields are:
+
+@table @asis
+@item @code{enable-network-configuration} (default: @code{#t}) (type: boolean)
+Setting this option to true enables @code{iwd} to configure the network
+interfaces with the IP addresses.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the General settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-network-settings
+Available @code{iwd-network-settings} fields are:
+
+@table @asis
+@item @code{enable-ipv6} (default: @code{#t}) (type: boolean)
+Sets the global default that tells @code{iwd} whether it should
+configure IPv6 addresses and routes
+
+@item @code{name-resolving-service} (default: @code{none}) (type: resolving-service)
+Configures a DNS resolution method used by the system.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the Network settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-scan-settings
+Available @code{iwd-scan-settings} fields are:
+
+@table @asis
+@item @code{disable-periodic-scan} (type: maybe-boolean)
+Setting this option to @code{#t} will prevent @code{iwd} from issuing
+the periodic scans for the available networks while disconnected.
+
+@item @code{initial-periodic-scan-interval} (type: maybe-number)
+The initial periodic scan interval upon disconnect (in seconds).
+
+@item @code{maximum-periodic-scan-interval} (type: maybe-number)
+The maximum periodic scan interval (in seconds).
+
+@item @code{disable-roaming-scan} (type: maybe-boolean)
+Setting this option to @code{#t} will prevent @code{iwd} from trying to
+scan when roaming decisions are activated.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the Scan settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
 @cindex ModemManager
 Some networking devices such as modems require special care, and this is
 what the services below focus on.
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 4cb7313808..dda0b8c2d0 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -41,6 +41,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu services networking)
+  #:use-module (gnu home services utils)
   #:use-module (gnu services)
   #:use-module (gnu services base)
   #:use-module (gnu services configuration)
@@ -80,6 +81,7 @@ (define-module (gnu services networking)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-43)
+  #:use-module ((ice-9 curried-definitions) #:select (define))
   #:use-module (ice-9 match)
   #:use-module (ice-9 string-fun)
   #:use-module (json)
@@ -233,6 +235,21 @@ (define-module (gnu services networking)
             wpa-supplicant-configuration-extra-options
             wpa-supplicant-service-type
 
+            iwd-configuration
+            iwd-configuration-config
+            iwd-configuration-ignored-interfaces
+            iwd-configuration-ignored-phys
+            iwd-configuration-interfaces
+            iwd-configuration-iwd
+            iwd-configuration-phys
+            iwd-configuration-shepherd-provision
+            iwd-configuration-shepherd-requirement
+            iwd-service-type
+            iwd-general-settings
+            iwd-network-settings
+            iwd-scan-settings
+            iwd-settings
+
             hostapd-configuration
             hostapd-configuration?
             hostapd-configuration-package
@@ -2083,6 +2100,226 @@ (define wpa-supplicant-service-type
 implements authentication, key negotiation and more for wireless networks.")
                   (default-value (wpa-supplicant-configuration)))))
 
+
+;;;
+;;; IWD
+;;;
+(define-enumerated-field-type resolving-service
+  (none systemd resolvconf))
+
+(define (iwd-uglify-field-name name)
+  (object->camel-case-string name 'upper))
+
+(define (iwd-serialize-base field-name val)
+  (format #f "~a=~a\n" field-name val))
+
+(define (iwd-serialize-field field-name val)
+  (iwd-serialize-base (iwd-uglify-field-name field-name) val))
+
+(define (iwd-serialize-boolean field-name value)
+  (iwd-serialize-field field-name (if value "true" "false")))
+
+(define (iwd-serialize-resolving-service field-name value)
+  (iwd-serialize-field field-name (object->string value)))
+
+(define (iwd-serialize-alist field-name value)
+  #~(string-append #$@(generic-serialize-alist list
+                                               iwd-serialize-base
+                                               value)))
+
+(define (serialize-list-of-strings _ value)
+  (string-join value "\n"))
+
+(define-maybe boolean (prefix iwd-))
+(define-maybe number (prefix iwd-))
+
+(define-configuration iwd-general-settings
+  (enable-network-configuration
+   (boolean #t)
+   "Setting this option to true enables @code{iwd} to configure the network
+interfaces with the IP addresses.")
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the General settings group.")
+
+  (prefix iwd-))
+
+(define-configuration iwd-network-settings
+  (enable-ipv6
+   (boolean #t)
+   "Sets the global default that tells @code{iwd} whether it should configure
+IPv6 addresses and routes")
+
+  (name-resolving-service
+   (resolving-service 'none)
+   "Configures a DNS resolution method used by the system.")
+
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the Network settings group.")
+
+  (prefix iwd-))
+
+(define-configuration iwd-scan-settings
+  (disable-periodic-scan
+   maybe-boolean
+   "Setting this option to @code{#t} will prevent @code{iwd} from issuing the
+periodic scans for the available networks while disconnected.")
+
+  (initial-periodic-scan-interval
+   maybe-number
+   "The initial periodic scan interval upon disconnect (in seconds).")
+
+  (maximum-periodic-scan-interval
+   maybe-number
+   "The maximum periodic scan interval (in seconds).")
+
+  (disable-roaming-scan
+   maybe-boolean
+   "Setting this option to @code{#t} will prevent @code{iwd} from trying to scan
+when roaming decisions are activated.")
+
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the Scan settings group.")
+
+  (prefix iwd-))
+
+(define-maybe iwd-network-settings)
+(define-maybe iwd-scan-settings)
+
+(define ((iwd-serialize-config-section fields) name cfg)
+  #~(format #f "[~a]\n~a\n"
+            (string-upcase (object->string '#$name) 0 1)
+            #$(serialize-configuration cfg fields)))
+
+(define serialize-iwd-network-settings
+  (iwd-serialize-config-section iwd-network-settings-fields))
+
+(define serialize-iwd-scan-settings
+  (iwd-serialize-config-section iwd-scan-settings-fields))
+
+(define serialize-iwd-general-settings
+  (iwd-serialize-config-section iwd-general-settings-fields))
+
+(define-configuration iwd-settings
+  (general
+   (iwd-general-settings (iwd-general-settings))
+   "General settings.")
+
+  (network
+   maybe-iwd-network-settings
+   "Network settings.")
+
+  (scan
+   maybe-iwd-scan-settings
+   "Scan settings.")
+
+  (extra-config
+   (list-of-strings '())
+   "Extra configuration values to append to the IWD configuration file."))
+
+(define-configuration/no-serialization iwd-configuration
+  (iwd
+   (file-like iwd)
+   "The IWD package to use.")
+
+  (interfaces
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will control.")
+
+  (ignored-interfaces
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will not manage.")
+
+  (phys
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will control.")
+
+  (ignored-phys
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will not manage.")
+
+  (shepherd-requirement
+   (list-of-symbols '())
+   "Shepherd requirements the service should depend on.")
+
+  (shepherd-provision
+   (list-of-symbols '(iwd))
+   "The name(s) of the service.")
+
+  (config
+   (iwd-settings (iwd-settings))
+   "Configuration settings."))
+
+(define (iwd-generate-documentation)
+  (configuration->documentation 'iwd-configuration)
+  (configuration->documentation 'iwd-settings)
+  (configuration->documentation 'iwd-general-settings)
+  (configuration->documentation 'iwd-network-settings)
+  (configuration->documentation 'iwd-scan-settings))
+
+(define (iwd-config-file config)
+  "Return an IWD configuration file."
+  (mixed-text-file "main.conf"
+                   (serialize-configuration
+                    (iwd-configuration-config config)
+                    iwd-settings-fields)))
+
+(define (iwd-shepherd-service config)
+  (match-record config <iwd-configuration>
+                (iwd interfaces ignored-interfaces
+                     phys ignored-phys
+                     shepherd-requirement shepherd-provision)
+
+    (list (shepherd-service
+           (documentation "Run Internet Wireless Daemon")
+           (provision shepherd-provision)
+           (requirement `(user-processes dbus-system loopback ,@shepherd-requirement))
+           (start #~(make-forkexec-constructor
+                     (list (string-append #$iwd "/libexec/iwd")
+                           "--logger=syslog"
+                           #$@(if (null? interfaces) '()
+                                  (list (string-append "--interfaces="
+                                                       (string-join interfaces ","))))
+                           #$@(if (null? ignored-interfaces) '()
+                                  (list (string-append "--nointerfaces="
+                                                       (string-join ignored-interfaces ","))))
+                           #$@(if (null? phys) '()
+                                  (list (string-append "--phys="
+                                                       (string-join phys ","))))
+                           #$@(if (null? ignored-phys) '()
+                                  (list (string-append "--nophys="
+                                                       (string-join ignored-phys ",")))))))
+           (stop #~(make-kill-destructor))))))
+
+(define (iwd-etc-service config)
+  `(("iwd/main.conf" ,(iwd-config-file config))))
+
+(define iwd-service-type
+  (let ((add-iwd-package (compose list iwd-configuration-iwd)))
+    (service-type (name 'iwd)
+                  (extensions
+                   (list (service-extension shepherd-root-service-type
+                                            iwd-shepherd-service)
+                         (service-extension etc-service-type
+                                            iwd-etc-service)
+                         (service-extension dbus-root-service-type
+                                            add-iwd-package)
+                         (service-extension profile-service-type
+                                            add-iwd-package)))
+                  (default-value (iwd-configuration))
+                  (description
+                   "Run @url{https://iwd.wiki.kernel.org/,Iwd},
+a network connection manager."))))
+
 
 ;;;
 ;;; Hostapd.
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Fri, 23 May 2025 09:05:02 GMT) Full text and rfc822 format available.

Message #17 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 1/3] services: configuration: Add define-enumerated-field-type
 helper.
Date: Fri, 23 May 2025 11:04:32 +0200
* gnu/services/cups.scm (define-enumerated-field-type): Move...
* gnu/services/configuration.scm (define-enumerated-field-type): ...here.
* gnu/services/vpn.scm (define-enumerated-field-type): Remove.
* gnu/services/power.scm
(define-enum): Replace with define-enumerated-field-type.

Change-Id: I89ec40f479e3f800268e714f1f88d638be017c7e
---
 gnu/services/configuration.scm | 14 +++++++++++
 gnu/services/cups.scm          | 12 ---------
 gnu/services/power.scm         | 45 +++++++++++-----------------------
 gnu/services/vpn.scm           | 12 ---------
 4 files changed, 28 insertions(+), 55 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 15eddd7665..6d9fd1feae 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -75,6 +75,7 @@ (define-module (gnu services configuration)
             configuration->documentation
             empty-serializer
             serialize-package
+            define-enumerated-field-type
 
             filter-configuration-fields
 
@@ -508,6 +509,19 @@ (define* (interpose ls  #:optional (delimiter "\n") (grammar 'infix))
                           (cons delimiter acc))))
               '() ls))
 
+(define-syntax define-enumerated-field-type
+  (lambda (x)
+    (syntax-case x (prefix)
+      ((_ name (option ...) (prefix serializer-prefix))
+       #`(begin
+           (define (#,(id #'name #'name #'?) x)
+             (memq x '(option ...)))
+           (define (#,(id #'name #'serializer-prefix #'serialize- #'name) field-name val)
+             (#,(id #'name #'serializer-prefix #'serialize-field) field-name val))))
+
+      ((_ name (option ...))
+       #`(define-enumerated-field-type name (option ...) (prefix #{}#))))))
+
 
 ;;;
 ;;; Commonly used predicates
diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index 738bb7f5cc..27aac7a16a 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -137,18 +137,6 @@ (define (non-negative-integer? val)
 (define (serialize-non-negative-integer field-name val)
   (serialize-field field-name val))
 
-(define-syntax define-enumerated-field-type
-  (lambda (x)
-    (define (id-append ctx . parts)
-      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
-    (syntax-case x ()
-      ((_ name (option ...))
-       #`(begin
-           (define (#,(id-append #'name #'name #'?) x)
-             (memq x '(option ...)))
-           (define (#,(id-append #'name #'serialize- #'name) field-name val)
-             (serialize-field field-name val)))))))
-
 (define-enumerated-field-type access-log-level
   (config actions all))
 (define-enumerated-field-type browse-local-protocols
diff --git a/gnu/services/power.scm b/gnu/services/power.scm
index ec8ae555d4..ad386549cd 100644
--- a/gnu/services/power.scm
+++ b/gnu/services/power.scm
@@ -204,23 +204,6 @@ (define-configuration/no-serialization apcupsd-event-handlers
     #~(#t))
    "The handler for the battattach event."))
 
-(define-syntax define-enum
-  (lambda (x)
-    (syntax-case x ()
-      ((_ name values)
-       (let* ((datum/name (syntax->datum #'name))
-              (datum/predicate (string->symbol
-                                (format #f "enum-~a?" datum/name)))
-              (datum/serialize (string->symbol
-                                (format #f "serialize-enum-~a" datum/name))))
-         (with-syntax
-             ((predicate (datum->syntax x datum/predicate))
-              (serialize (datum->syntax x datum/serialize)))
-           #'(begin
-               (define (predicate value)
-                 (memq value values))
-               (define serialize serialize-symbol))))))))
-
 (define mangle-field-name
   (match-lambda
     ('name                            "UPSNAME")
@@ -252,25 +235,25 @@ (define mangle-field-name
     ('data-time                       "DATATIME")
     ('facility                        "FACILITY")))
 
-(define (serialize-string field-name value)
+(define (serialize-field field-name value)
   #~(format #f "~a ~a\n" #$(mangle-field-name field-name) '#$value))
-(define serialize-symbol serialize-string)
-(define serialize-integer serialize-string)
+(define serialize-string serialize-field)
+(define serialize-symbol serialize-field)
+(define serialize-integer serialize-field)
 (define (serialize-boolean field-name value)
-  #~(format #f "~a ~a\n"
-            #$(mangle-field-name field-name)
-            #$(if value "on" "off")))
+  (serialize-field field-name (if value "on" "off")))
 
 (define-maybe string)
 
-(define-enum cable '( simple smart ether usb
-                      940-0119A 940-0127A 940-0128A 940-0020B 940-0020C
-                      940-0023A 940-0024B 940-0024C 940-1524C 940-0024G
-                      940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000))
-(define-enum type '(apcsmart usb net snmp netsnmp dumb pcnet modbus test))
-(define-enum no-logon '(disable timeout percent minutes always))
-(define-enum class '(standalone shareslave sharemaster))
-(define-enum mode '(disable share))
+(define-enumerated-field-type enum-cable
+   ( simple smart ether usb
+     940-0119A 940-0127A 940-0128A 940-0020B 940-0020C
+     940-0023A 940-0024B 940-0024C 940-1524C 940-0024G
+     940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000))
+(define-enumerated-field-type enum-type (apcsmart usb net snmp netsnmp dumb pcnet modbus test))
+(define-enumerated-field-type enum-no-logon (disable timeout percent minutes always))
+(define-enumerated-field-type enum-class (standalone shareslave sharemaster))
+(define-enumerated-field-type enum-mode (disable share))
 
 (define-configuration apcupsd-configuration
   (apcupsd (package apcupsd) "The @code{apcupsd} package to use.")
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index f97cbac7bb..56022ac27a 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -141,18 +141,6 @@ (define (ip-mask? val)
            #f)))
 (define serialize-ip-mask serialize-string)
 
-(define-syntax define-enumerated-field-type
-  (lambda (x)
-    (define (id-append ctx . parts)
-      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
-    (syntax-case x ()
-      ((_ name (option ...))
-       #`(begin
-           (define (#,(id-append #'name #'name #'?) x)
-             (memq x '(option ...)))
-           (define (#,(id-append #'name #'serialize- #'name) field-name val)
-             (serialize-field field-name val)))))))
-
 (define-enumerated-field-type proto
   (udp tcp udp6 tcp6))
 (define-enumerated-field-type dev

base-commit: 60025c2425dbac99df1219ed907c7c55e454b932
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Fri, 23 May 2025 09:05:03 GMT) Full text and rfc822 format available.

Message #20 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 2/3] services: networking: Add shepherd-requirement for dhcpcd.
Date: Fri, 23 May 2025 11:04:33 +0200
* gnu/services/networking.scm (dhcpcd-configuration): Add
shepherd-requirement field.
(dhcpcd-shepherd-service): Use it.
* doc/guix.texi (Networking Setup): Regenerate dhcpcd-configuration
documentation.
(File Systems): Fix typo.

Change-Id: Id347e2bed2569237685a47be82dbf686640db25b
---
 doc/guix.texi               | 17 +++++++++++------
 gnu/services/networking.scm | 31 +++++++++++++++++++------------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 02f472246a..3ef2e50e57 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18332,7 +18332,7 @@ File Systems
 might not be sufficient as @code{networking} being marked as started
 does @emph{not} imply the network has already been configured and in
 working order (for example, when using
-@code{dhcpcd-client-service-type}).  For such cases, adding a
+@code{dhcp-client-service-type}).  For such cases, adding a
 requirement on a custom @code{network-online} service may be necessary.
 A sample @code{network-online} one-shot Shepherd service implementation
 is provided below:
@@ -21980,12 +21980,13 @@ Networking Setup
 @item @code{duid} (default: @code{""}) (type: maybe-string)
 DHCPv4 clients require a unique client identifier, this option uses the
 DHCPv6 Unique Identifier as a DHCPv4 client identifier as well.  For
-more information, refer to @uref{https://www.rfc-editor.org/rfc/rfc4361, RFC 4361}
-and @code{dhcpcd.conf(5)}.
+more information, refer to
+@uref{https://www.rfc-editor.org/rfc/rfc4361,RFC 4361} and
+@code{dhcpcd.conf(5)}.
 
 @item @code{persistent?} (default: @code{#t}) (type: boolean)
-When true, automatically de-configure the interface when @command{dhcpcd}
-exits.
+When true, automatically de-configure the interface when
+@command{dhcpcd} exits.
 
 @item @code{option} (default: @code{("rapid_commit" "domain_name_servers" "domain_name" "domain_search" "host_name" "classless_static_routes" "interface_mtu")}) (type: list-of-strings)
 List of options to request from the server.
@@ -22019,9 +22020,13 @@ Networking Setup
 @item @code{extra-content} (type: maybe-string)
 Extra content to append to the configuration as-is.
 
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+This is a list of symbols naming Shepherd services that this service
+will depend on.
+
 @end table
-@end deftp
 
+@end deftp
 
 @cindex NetworkManager
 
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 67653e2cbf..4cb7313808 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -126,6 +126,7 @@ (define-module (gnu services networking)
             dhcpcd-configuration-vendor-class-id
             dhcpcd-configuration-client-id
             dhcpcd-configuration-extra-content
+            dhcpcd-configuration-shepherd-requirement
 
             ntp-configuration
             ntp-configuration?
@@ -609,6 +610,12 @@ (define-configuration dhcpcd-configuration
     maybe-string
     "Extra content to append to the configuration as-is.")
 
+  (shepherd-requirement
+   (list-of-symbols '())
+   "This is a list of symbols naming Shepherd services that this service
+will depend on."
+   empty-serializer)
+
   (prefix dhcpcd-))
 
 (define (dhcpcd-config-file config)
@@ -628,19 +635,19 @@ (define dhcpcd-account-service
           (shell (file-append shadow "/sbin/nologin")))))
 
 (define (dhcpcd-shepherd-service config)
-  (let* ((config-file (dhcpcd-config-file config))
-         (command-args (dhcpcd-configuration-command-arguments config))
-         (ifaces (dhcpcd-configuration-interfaces config)))
-    (list (shepherd-service
-            (documentation "dhcpcd daemon.")
-            (provision '(networking))
-            (requirement '(user-processes udev))
-            (actions (list (shepherd-configuration-action config-file)))
-            (start
+  (match-record config <dhcpcd-configuration>
+                (command-arguments interfaces shepherd-requirement)
+    (let ((config-file (dhcpcd-config-file config)))
+      (list (shepherd-service
+             (documentation "dhcpcd daemon.")
+             (provision '(networking))
+             (requirement `(user-processes udev ,@shepherd-requirement))
+             (actions (list (shepherd-configuration-action config-file)))
+             (start
               #~(make-forkexec-constructor
-                    (list (string-append #$dhcpcd "/sbin/dhcpcd")
-                          #$@command-args "-B" "-f" #$config-file #$@ifaces)))
-            (stop #~(make-kill-destructor))))))
+                 (list (string-append #$dhcpcd "/sbin/dhcpcd")
+                       #$@command-arguments "-B" "-f" #$config-file #$@interfaces)))
+             (stop #~(make-kill-destructor)))))))
 
 (define dhcpcd-service-type
   (service-type (name 'dhcpcd)
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Fri, 23 May 2025 09:06:02 GMT) Full text and rfc822 format available.

Message #23 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH 3/3] services: networking: Add iwd-service-type.
Date: Fri, 23 May 2025 11:04:34 +0200
* gnu/services/networking.scm (iwd-service-type): New service type.
(iwd-configuration), (iwd-settings), (iwd-scan-settings),
(iwd-general-settings), (iwd-network-settings): New configuration types.
* doc/guix.texi (Networking setup): Document it.

Change-Id: I852115b9c6768b3ec4eedb34a7f9e66438bd1429
---
 doc/guix.texi               | 157 ++++++++++++++++++++++++
 gnu/services/networking.scm | 236 ++++++++++++++++++++++++++++++++++++
 2 files changed, 393 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3ef2e50e57..5c07b35ccb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22404,6 +22404,163 @@ Networking Setup
 @end table
 @end deftp
 
+@cindex IWD
+@defvar iwd-service-type
+This is the service type to run @acronyml{IWD,Internet Wireless Daemon},
+a wireless daemon required to authenticate against encrypted WiFi
+networks.
+@end defvar
+
+@quotation Warning
+By default @code{iwd} removes and re-creates interfaces it manages.  It
+doesn't play nicely with @code{dhcp-client-service-type} that enumerates
+wireless interfaces before starting the Shepherd service.  Use either
+@code{dhcpcd-service-type} or the @code{iwd}'s built-in DHCP client (see
+@code{enable-network-configuration} option below).
+@end quotation
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-configuration
+Available @code{iwd-configuration} fields are:
+
+@table @asis
+@item @code{iwd} (default: @code{iwd}) (type: file-like)
+The IWD package to use.
+
+@item @code{interfaces} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will control.
+
+@item @code{ignored-interfaces} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will not manage.
+
+@item @code{phys} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will control.
+
+@item @code{ignored-phys} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will not manage.
+
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+Shepherd requirements the service should depend on.
+
+@item @code{shepherd-provision} (default: @code{(iwd)}) (type: list-of-symbols)
+The name(s) of the service.
+
+@item @code{config} (type: iwd-settings)
+Configuration settings.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-settings
+Available @code{iwd-settings} fields are:
+
+@table @asis
+@item @code{general} (type: iwd-general-settings)
+General settings.
+
+@item @code{network} (type: maybe-iwd-network-settings)
+Network settings.
+
+@item @code{scan} (type: maybe-iwd-scan-settings)
+Scan settings.
+
+@item @code{extra-config} (default: @code{()}) (type: list-of-strings)
+Extra configuration values to append to the IWD configuration file.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-general-settings
+Available @code{iwd-general-settings} fields are:
+
+@table @asis
+@item @code{enable-network-configuration} (default: @code{#f}) (type: boolean)
+Setting this option to true enables @code{iwd} to configure the network
+interfaces with the IP addresses.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the General settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-network-settings
+Available @code{iwd-network-settings} fields are:
+
+@table @asis
+@item @code{enable-ipv6} (default: @code{#t}) (type: boolean)
+Sets the global default that tells @code{iwd} whether it should
+configure IPv6 addresses and routes
+
+@item @code{name-resolving-service} (default: @code{none}) (type: resolving-service)
+Configures a DNS resolution method used by the system.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the Network settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-scan-settings
+Available @code{iwd-scan-settings} fields are:
+
+@table @asis
+@item @code{disable-periodic-scan} (type: maybe-boolean)
+Setting this option to @code{#t} will prevent @code{iwd} from issuing
+the periodic scans for the available networks while disconnected.
+
+@item @code{initial-periodic-scan-interval} (type: maybe-number)
+The initial periodic scan interval upon disconnect (in seconds).
+
+@item @code{maximum-periodic-scan-interval} (type: maybe-number)
+The maximum periodic scan interval (in seconds).
+
+@item @code{disable-roaming-scan} (type: maybe-boolean)
+Setting this option to @code{#t} will prevent @code{iwd} from trying to
+scan when roaming decisions are activated.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the Scan settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
 @cindex ModemManager
 Some networking devices such as modems require special care, and this is
 what the services below focus on.
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 4cb7313808..86a6859a66 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -41,6 +41,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu services networking)
+  #:use-module (gnu home services utils)
   #:use-module (gnu services)
   #:use-module (gnu services base)
   #:use-module (gnu services configuration)
@@ -80,6 +81,7 @@ (define-module (gnu services networking)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-43)
+  #:use-module ((ice-9 curried-definitions) #:select (define))
   #:use-module (ice-9 match)
   #:use-module (ice-9 string-fun)
   #:use-module (json)
@@ -233,6 +235,21 @@ (define-module (gnu services networking)
             wpa-supplicant-configuration-extra-options
             wpa-supplicant-service-type
 
+            iwd-configuration
+            iwd-configuration-config
+            iwd-configuration-ignored-interfaces
+            iwd-configuration-ignored-phys
+            iwd-configuration-interfaces
+            iwd-configuration-iwd
+            iwd-configuration-phys
+            iwd-configuration-shepherd-provision
+            iwd-configuration-shepherd-requirement
+            iwd-service-type
+            iwd-general-settings
+            iwd-network-settings
+            iwd-scan-settings
+            iwd-settings
+
             hostapd-configuration
             hostapd-configuration?
             hostapd-configuration-package
@@ -2083,6 +2100,225 @@ (define wpa-supplicant-service-type
 implements authentication, key negotiation and more for wireless networks.")
                   (default-value (wpa-supplicant-configuration)))))
 
+
+;;;
+;;; IWD
+;;;
+(define (iwd-uglify-field-name name)
+  (object->camel-case-string name 'upper))
+
+(define (iwd-serialize-base field-name val)
+  (format #f "~a=~a\n" field-name val))
+
+(define (iwd-serialize-field field-name val)
+  (iwd-serialize-base (iwd-uglify-field-name field-name) val))
+
+(define iwd-serialize-number iwd-serialize-field)
+
+(define (iwd-serialize-boolean field-name value)
+  (iwd-serialize-field field-name (if value "true" "false")))
+
+(define (iwd-serialize-alist field-name value)
+  (if (null? value)
+      ""
+      #~(string-append #$@(generic-serialize-alist list
+                                                   iwd-serialize-base
+                                                   value))))
+
+(define-maybe boolean (prefix iwd-))
+(define-maybe number (prefix iwd-))
+(define-enumerated-field-type resolving-service
+  (none systemd resolvconf)
+  (prefix iwd-))
+
+(define-configuration iwd-general-settings
+  (enable-network-configuration
+   (boolean #f)
+   "Setting this option to true enables @code{iwd} to configure the network
+interfaces with the IP addresses.")
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the General settings group.")
+
+  (prefix iwd-))
+
+(define-configuration iwd-network-settings
+  (enable-ipv6
+   (boolean #t)
+   "Sets the global default that tells @code{iwd} whether it should configure
+IPv6 addresses and routes")
+
+  (name-resolving-service
+   (resolving-service 'none)
+   "Configures a DNS resolution method used by the system.")
+
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the Network settings group.")
+
+  (prefix iwd-))
+
+(define-configuration iwd-scan-settings
+  (disable-periodic-scan
+   maybe-boolean
+   "Setting this option to @code{#t} will prevent @code{iwd} from issuing the
+periodic scans for the available networks while disconnected.")
+
+  (initial-periodic-scan-interval
+   maybe-number
+   "The initial periodic scan interval upon disconnect (in seconds).")
+
+  (maximum-periodic-scan-interval
+   maybe-number
+   "The maximum periodic scan interval (in seconds).")
+
+  (disable-roaming-scan
+   maybe-boolean
+   "Setting this option to @code{#t} will prevent @code{iwd} from trying to scan
+when roaming decisions are activated.")
+
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the Scan settings group.")
+
+  (prefix iwd-))
+
+(define-maybe iwd-network-settings)
+(define-maybe iwd-scan-settings)
+
+(define ((iwd-serialize-config-section fields) name cfg)
+  #~(format #f "[~a]\n~a\n"
+            #$(string-upcase (object->string name) 0 1)
+            #$(serialize-configuration cfg fields)))
+
+(define serialize-iwd-network-settings
+  (iwd-serialize-config-section iwd-network-settings-fields))
+
+(define serialize-iwd-scan-settings
+  (iwd-serialize-config-section iwd-scan-settings-fields))
+
+(define serialize-iwd-general-settings
+  (iwd-serialize-config-section iwd-general-settings-fields))
+
+(define-configuration iwd-settings
+  (general
+   (iwd-general-settings (iwd-general-settings))
+   "General settings.")
+
+  (network
+   maybe-iwd-network-settings
+   "Network settings.")
+
+  (scan
+   maybe-iwd-scan-settings
+   "Scan settings.")
+
+  (extra-config
+   (list-of-strings '())
+   "Extra configuration values to append to the IWD configuration file."
+   (serializer (lambda (_ value) (string-join value "\n" 'suffix)))))
+
+(define-configuration/no-serialization iwd-configuration
+  (iwd
+   (file-like iwd)
+   "The IWD package to use.")
+
+  (interfaces
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will control.")
+
+  (ignored-interfaces
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will not manage.")
+
+  (phys
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will control.")
+
+  (ignored-phys
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will not manage.")
+
+  (shepherd-requirement
+   (list-of-symbols '())
+   "Shepherd requirements the service should depend on.")
+
+  (shepherd-provision
+   (list-of-symbols '(iwd))
+   "The name(s) of the service.")
+
+  (config
+   (iwd-settings (iwd-settings))
+   "Configuration settings."))
+
+(define (iwd-generate-documentation)
+  (configuration->documentation 'iwd-configuration)
+  (configuration->documentation 'iwd-settings)
+  (configuration->documentation 'iwd-general-settings)
+  (configuration->documentation 'iwd-network-settings)
+  (configuration->documentation 'iwd-scan-settings))
+
+(define (iwd-config-file config)
+  "Return an IWD configuration file."
+  (mixed-text-file "main.conf"
+                   (serialize-configuration
+                    (iwd-configuration-config config)
+                    iwd-settings-fields)))
+
+(define (iwd-shepherd-service config)
+  (match-record config <iwd-configuration>
+                (iwd interfaces ignored-interfaces
+                     phys ignored-phys
+                     shepherd-requirement shepherd-provision)
+
+    (list (shepherd-service
+           (documentation "Run Internet Wireless Daemon")
+           (provision shepherd-provision)
+           (requirement `(user-processes dbus-system loopback ,@shepherd-requirement))
+           (start #~(make-forkexec-constructor
+                     (list (string-append #$iwd "/libexec/iwd")
+                           "--logger=syslog"
+                           #$@(if (null? interfaces) '()
+                                  (list (string-append "--interfaces="
+                                                       (string-join interfaces ","))))
+                           #$@(if (null? ignored-interfaces) '()
+                                  (list (string-append "--nointerfaces="
+                                                       (string-join ignored-interfaces ","))))
+                           #$@(if (null? phys) '()
+                                  (list (string-append "--phys="
+                                                       (string-join phys ","))))
+                           #$@(if (null? ignored-phys) '()
+                                  (list (string-append "--nophys="
+                                                       (string-join ignored-phys ",")))))))
+           (stop #~(make-kill-destructor))))))
+
+(define (iwd-etc-service config)
+  `(("iwd/main.conf" ,(iwd-config-file config))))
+
+(define iwd-service-type
+  (let ((add-iwd-package (compose list iwd-configuration-iwd)))
+    (service-type (name 'iwd)
+                  (extensions
+                   (list (service-extension shepherd-root-service-type
+                                            iwd-shepherd-service)
+                         (service-extension etc-service-type
+                                            iwd-etc-service)
+                         (service-extension dbus-root-service-type
+                                            add-iwd-package)
+                         (service-extension profile-service-type
+                                            add-iwd-package)))
+                  (default-value (iwd-configuration))
+                  (description
+                   "Run @url{https://iwd.wiki.kernel.org/,Iwd},
+a network connection manager."))))
+
 
 ;;;
 ;;; Hostapd.
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Fri, 23 May 2025 09:36:02 GMT) Full text and rfc822 format available.

Message #26 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sergey Trofimov <sarg <at> sarg.org.ru>
Cc: Gabriel Wicki <gabriel <at> erlikon.ch>,
 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, 78546 <at> debbugs.gnu.org
Subject: Re: [bug#78546] [PATCH 2/3] services: networking: Add
 shepherd-requirement for dhcpcd.
Date: Fri, 23 May 2025 11:33:25 +0200
Sergey Trofimov <sarg <at> sarg.org.ru> writes:

> * gnu/services/networking.scm (dhcpcd-configuration): Add
> shepherd-requirement field.
> (dhcpcd-shepherd-service): Use it.
> * doc/guix.texi (Networking Setup): Regenerate dhcpcd-configuration
> documentation.
> (File Systems): Fix typo.
>
> Change-Id: Id347e2bed2569237685a47be82dbf686640db25b

LGTM.




Information forwarded to guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Fri, 23 May 2025 09:36:02 GMT) Full text and rfc822 format available.

Message #29 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sergey Trofimov <sarg <at> sarg.org.ru>
Cc: Gabriel Wicki <gabriel <at> erlikon.ch>,
 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, 78546 <at> debbugs.gnu.org
Subject: Re: [bug#78546] [PATCH 3/3] services: networking: Add
 iwd-service-type.
Date: Fri, 23 May 2025 11:32:34 +0200
Hi Sergey,

Sergey Trofimov <sarg <at> sarg.org.ru> writes:

> * gnu/services/networking.scm (iwd-service-type): New service type.
> (iwd-configuration), (iwd-settings), (iwd-scan-settings),
> (iwd-general-settings), (iwd-network-settings): New configuration types.
> * doc/guix.texi (Networking setup): Document it.
>
> Change-Id: I852115b9c6768b3ec4eedb34a7f9e66438bd1429

[…]

> +@defvar iwd-service-type
> +This is the service type to run @acronyml{IWD,Internet Wireless Daemon},
> +a wireless daemon required to authenticate against encrypted WiFi
> +networks.

Am I right that this conflicts with wpa-supplicant, which is what
NetworkManager uses?  Should this be mentioned?

> +@deftp {Data Type} iwd-scan-settings
> +Available @code{iwd-scan-settings} fields are:
> +
> +@table @asis
> +@item @code{disable-periodic-scan} (type: maybe-boolean)

As a rule of thumb, I recommend avoiding negatives for Booleans; also
add a question mark.

So this would become ‘enable-periodic-scan?’, defaulting to #t.

And it can be ‘boolean’ rather than ‘maybe-boolean’ (the latter would
default to “unset”, whose meaning isn’t clear here).

Same for ‘disable-roaming-scan’.

> +@item @code{initial-periodic-scan-interval} (type: maybe-number)
> +The initial periodic scan interval upon disconnect (in seconds).
> +
> +@item @code{maximum-periodic-scan-interval} (type: maybe-number)
> +The maximum periodic scan interval (in seconds).

I would tend to provide a known default value and make it ‘number’
instead of ‘maybe-number’.

The rest LGTM.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Fri, 23 May 2025 12:39:02 GMT) Full text and rfc822 format available.

Message #32 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Gabriel Wicki <gabriel <at> erlikon.ch>,
 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, 78546 <at> debbugs.gnu.org
Subject: Re: [bug#78546] [PATCH 3/3] services: networking: Add
 iwd-service-type.
Date: Fri, 23 May 2025 14:38:27 +0200
Hi Ludovic,

thanks for the review, I've answered a couple points below

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Sergey,
>
> Sergey Trofimov <sarg <at> sarg.org.ru> writes:
>
>> * gnu/services/networking.scm (iwd-service-type): New service type.
>> (iwd-configuration), (iwd-settings), (iwd-scan-settings),
>> (iwd-general-settings), (iwd-network-settings): New configuration types.
>> * doc/guix.texi (Networking setup): Document it.
>>
>> Change-Id: I852115b9c6768b3ec4eedb34a7f9e66438bd1429
>
> […]
>
>> +@defvar iwd-service-type
>> +This is the service type to run @acronyml{IWD,Internet Wireless Daemon},
>> +a wireless daemon required to authenticate against encrypted WiFi
>> +networks.
>
> Am I right that this conflicts with wpa-supplicant, which is what
> NetworkManager uses?  Should this be mentioned?
>

Sure, I'll also add 'wireless-daemon' to both iwd and wpa-supplicant
shepherd's provisions. This way a conflict in the config would result in
an error message.

>
>> +@deftp {Data Type} iwd-scan-settings
>> +Available @code{iwd-scan-settings} fields are:
>> +
>> +@table @asis
>> +@item @code{disable-periodic-scan} (type: maybe-boolean)
>
> As a rule of thumb, I recommend avoiding negatives for Booleans; also
> add a question mark.
>

These are the names of iwd settings, see man 5 iwd.config. I will add
question marks for booleans, but I'd rather leave the names as they're
defined by iwd authors.

>
> So this would become ‘enable-periodic-scan?’, defaulting to #t.
>
> And it can be ‘boolean’ rather than ‘maybe-boolean’ (the latter would
> default to “unset”, whose meaning isn’t clear here).
>
> Same for ‘disable-roaming-scan’.
>
>> +@item @code{initial-periodic-scan-interval} (type: maybe-number)
>> +The initial periodic scan interval upon disconnect (in seconds).
>> +
>> +@item @code{maximum-periodic-scan-interval} (type: maybe-number)
>> +The maximum periodic scan interval (in seconds).
>
> I would tend to provide a known default value and make it ‘number’
> instead of ‘maybe-number’.
>

I agree, I'll change that.




Information forwarded to sarg <at> sarg.org.ru, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Sat, 24 May 2025 13:02:03 GMT) Full text and rfc822 format available.

Message #35 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH v2 1/5] services: configuration: Add
 define-enumerated-field-type helper.
Date: Sat, 24 May 2025 15:01:28 +0200
* gnu/services/cups.scm (define-enumerated-field-type): Move...
* gnu/services/configuration.scm (define-enumerated-field-type): ...here.
* gnu/services/vpn.scm (define-enumerated-field-type): Remove.
* gnu/services/power.scm
(define-enum): Replace with define-enumerated-field-type.

Change-Id: I89ec40f479e3f800268e714f1f88d638be017c7e
---
 gnu/services/configuration.scm | 14 +++++++++++
 gnu/services/cups.scm          | 12 ---------
 gnu/services/power.scm         | 45 +++++++++++-----------------------
 gnu/services/vpn.scm           | 12 ---------
 4 files changed, 28 insertions(+), 55 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 15eddd7665..6d9fd1feae 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -75,6 +75,7 @@ (define-module (gnu services configuration)
             configuration->documentation
             empty-serializer
             serialize-package
+            define-enumerated-field-type
 
             filter-configuration-fields
 
@@ -508,6 +509,19 @@ (define* (interpose ls  #:optional (delimiter "\n") (grammar 'infix))
                           (cons delimiter acc))))
               '() ls))
 
+(define-syntax define-enumerated-field-type
+  (lambda (x)
+    (syntax-case x (prefix)
+      ((_ name (option ...) (prefix serializer-prefix))
+       #`(begin
+           (define (#,(id #'name #'name #'?) x)
+             (memq x '(option ...)))
+           (define (#,(id #'name #'serializer-prefix #'serialize- #'name) field-name val)
+             (#,(id #'name #'serializer-prefix #'serialize-field) field-name val))))
+
+      ((_ name (option ...))
+       #`(define-enumerated-field-type name (option ...) (prefix #{}#))))))
+
 
 ;;;
 ;;; Commonly used predicates
diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index 738bb7f5cc..27aac7a16a 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -137,18 +137,6 @@ (define (non-negative-integer? val)
 (define (serialize-non-negative-integer field-name val)
   (serialize-field field-name val))
 
-(define-syntax define-enumerated-field-type
-  (lambda (x)
-    (define (id-append ctx . parts)
-      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
-    (syntax-case x ()
-      ((_ name (option ...))
-       #`(begin
-           (define (#,(id-append #'name #'name #'?) x)
-             (memq x '(option ...)))
-           (define (#,(id-append #'name #'serialize- #'name) field-name val)
-             (serialize-field field-name val)))))))
-
 (define-enumerated-field-type access-log-level
   (config actions all))
 (define-enumerated-field-type browse-local-protocols
diff --git a/gnu/services/power.scm b/gnu/services/power.scm
index ec8ae555d4..ad386549cd 100644
--- a/gnu/services/power.scm
+++ b/gnu/services/power.scm
@@ -204,23 +204,6 @@ (define-configuration/no-serialization apcupsd-event-handlers
     #~(#t))
    "The handler for the battattach event."))
 
-(define-syntax define-enum
-  (lambda (x)
-    (syntax-case x ()
-      ((_ name values)
-       (let* ((datum/name (syntax->datum #'name))
-              (datum/predicate (string->symbol
-                                (format #f "enum-~a?" datum/name)))
-              (datum/serialize (string->symbol
-                                (format #f "serialize-enum-~a" datum/name))))
-         (with-syntax
-             ((predicate (datum->syntax x datum/predicate))
-              (serialize (datum->syntax x datum/serialize)))
-           #'(begin
-               (define (predicate value)
-                 (memq value values))
-               (define serialize serialize-symbol))))))))
-
 (define mangle-field-name
   (match-lambda
     ('name                            "UPSNAME")
@@ -252,25 +235,25 @@ (define mangle-field-name
     ('data-time                       "DATATIME")
     ('facility                        "FACILITY")))
 
-(define (serialize-string field-name value)
+(define (serialize-field field-name value)
   #~(format #f "~a ~a\n" #$(mangle-field-name field-name) '#$value))
-(define serialize-symbol serialize-string)
-(define serialize-integer serialize-string)
+(define serialize-string serialize-field)
+(define serialize-symbol serialize-field)
+(define serialize-integer serialize-field)
 (define (serialize-boolean field-name value)
-  #~(format #f "~a ~a\n"
-            #$(mangle-field-name field-name)
-            #$(if value "on" "off")))
+  (serialize-field field-name (if value "on" "off")))
 
 (define-maybe string)
 
-(define-enum cable '( simple smart ether usb
-                      940-0119A 940-0127A 940-0128A 940-0020B 940-0020C
-                      940-0023A 940-0024B 940-0024C 940-1524C 940-0024G
-                      940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000))
-(define-enum type '(apcsmart usb net snmp netsnmp dumb pcnet modbus test))
-(define-enum no-logon '(disable timeout percent minutes always))
-(define-enum class '(standalone shareslave sharemaster))
-(define-enum mode '(disable share))
+(define-enumerated-field-type enum-cable
+   ( simple smart ether usb
+     940-0119A 940-0127A 940-0128A 940-0020B 940-0020C
+     940-0023A 940-0024B 940-0024C 940-1524C 940-0024G
+     940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000))
+(define-enumerated-field-type enum-type (apcsmart usb net snmp netsnmp dumb pcnet modbus test))
+(define-enumerated-field-type enum-no-logon (disable timeout percent minutes always))
+(define-enumerated-field-type enum-class (standalone shareslave sharemaster))
+(define-enumerated-field-type enum-mode (disable share))
 
 (define-configuration apcupsd-configuration
   (apcupsd (package apcupsd) "The @code{apcupsd} package to use.")
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index f97cbac7bb..56022ac27a 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -141,18 +141,6 @@ (define (ip-mask? val)
            #f)))
 (define serialize-ip-mask serialize-string)
 
-(define-syntax define-enumerated-field-type
-  (lambda (x)
-    (define (id-append ctx . parts)
-      (datum->syntax ctx (apply symbol-append (map syntax->datum parts))))
-    (syntax-case x ()
-      ((_ name (option ...))
-       #`(begin
-           (define (#,(id-append #'name #'name #'?) x)
-             (memq x '(option ...)))
-           (define (#,(id-append #'name #'serialize- #'name) field-name val)
-             (serialize-field field-name val)))))))
-
 (define-enumerated-field-type proto
   (udp tcp udp6 tcp6))
 (define-enumerated-field-type dev

base-commit: 0c799ea004129c487a0aa8573d2e3e0839c84b2f
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, ludo <at> gnu.org, gabriel <at> erlikon.ch, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Sat, 24 May 2025 13:02:03 GMT) Full text and rfc822 format available.

Message #38 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH v2 2/5] services: networking: Add shepherd-requirement for
 dhcpcd.
Date: Sat, 24 May 2025 15:01:29 +0200
* gnu/services/networking.scm (dhcpcd-configuration): Add
shepherd-requirement field.
(dhcpcd-shepherd-service): Use it.
* doc/guix.texi (Networking Setup): Regenerate dhcpcd-configuration
documentation.
(File Systems): Fix typo.

Change-Id: Id347e2bed2569237685a47be82dbf686640db25b
---
 doc/guix.texi               | 17 +++++++++++------
 gnu/services/networking.scm | 31 +++++++++++++++++++------------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index e4e2b853f1..502482b754 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18332,7 +18332,7 @@ File Systems
 might not be sufficient as @code{networking} being marked as started
 does @emph{not} imply the network has already been configured and in
 working order (for example, when using
-@code{dhcpcd-client-service-type}).  For such cases, adding a
+@code{dhcp-client-service-type}).  For such cases, adding a
 requirement on a custom @code{network-online} service may be necessary.
 A sample @code{network-online} one-shot Shepherd service implementation
 is provided below:
@@ -21980,12 +21980,13 @@ Networking Setup
 @item @code{duid} (default: @code{""}) (type: maybe-string)
 DHCPv4 clients require a unique client identifier, this option uses the
 DHCPv6 Unique Identifier as a DHCPv4 client identifier as well.  For
-more information, refer to @uref{https://www.rfc-editor.org/rfc/rfc4361, RFC 4361}
-and @code{dhcpcd.conf(5)}.
+more information, refer to
+@uref{https://www.rfc-editor.org/rfc/rfc4361,RFC 4361} and
+@code{dhcpcd.conf(5)}.
 
 @item @code{persistent?} (default: @code{#t}) (type: boolean)
-When true, automatically de-configure the interface when @command{dhcpcd}
-exits.
+When true, automatically de-configure the interface when
+@command{dhcpcd} exits.
 
 @item @code{option} (default: @code{("rapid_commit" "domain_name_servers" "domain_name" "domain_search" "host_name" "classless_static_routes" "interface_mtu")}) (type: list-of-strings)
 List of options to request from the server.
@@ -22019,9 +22020,13 @@ Networking Setup
 @item @code{extra-content} (type: maybe-string)
 Extra content to append to the configuration as-is.
 
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+This is a list of symbols naming Shepherd services that this service
+will depend on.
+
 @end table
-@end deftp
 
+@end deftp
 
 @cindex NetworkManager
 
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 67653e2cbf..4cb7313808 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -126,6 +126,7 @@ (define-module (gnu services networking)
             dhcpcd-configuration-vendor-class-id
             dhcpcd-configuration-client-id
             dhcpcd-configuration-extra-content
+            dhcpcd-configuration-shepherd-requirement
 
             ntp-configuration
             ntp-configuration?
@@ -609,6 +610,12 @@ (define-configuration dhcpcd-configuration
     maybe-string
     "Extra content to append to the configuration as-is.")
 
+  (shepherd-requirement
+   (list-of-symbols '())
+   "This is a list of symbols naming Shepherd services that this service
+will depend on."
+   empty-serializer)
+
   (prefix dhcpcd-))
 
 (define (dhcpcd-config-file config)
@@ -628,19 +635,19 @@ (define dhcpcd-account-service
           (shell (file-append shadow "/sbin/nologin")))))
 
 (define (dhcpcd-shepherd-service config)
-  (let* ((config-file (dhcpcd-config-file config))
-         (command-args (dhcpcd-configuration-command-arguments config))
-         (ifaces (dhcpcd-configuration-interfaces config)))
-    (list (shepherd-service
-            (documentation "dhcpcd daemon.")
-            (provision '(networking))
-            (requirement '(user-processes udev))
-            (actions (list (shepherd-configuration-action config-file)))
-            (start
+  (match-record config <dhcpcd-configuration>
+                (command-arguments interfaces shepherd-requirement)
+    (let ((config-file (dhcpcd-config-file config)))
+      (list (shepherd-service
+             (documentation "dhcpcd daemon.")
+             (provision '(networking))
+             (requirement `(user-processes udev ,@shepherd-requirement))
+             (actions (list (shepherd-configuration-action config-file)))
+             (start
               #~(make-forkexec-constructor
-                    (list (string-append #$dhcpcd "/sbin/dhcpcd")
-                          #$@command-args "-B" "-f" #$config-file #$@ifaces)))
-            (stop #~(make-kill-destructor))))))
+                 (list (string-append #$dhcpcd "/sbin/dhcpcd")
+                       #$@command-arguments "-B" "-f" #$config-file #$@interfaces)))
+             (stop #~(make-kill-destructor)))))))
 
 (define dhcpcd-service-type
   (service-type (name 'dhcpcd)
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, ludo <at> gnu.org, gabriel <at> erlikon.ch, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Sat, 24 May 2025 13:03:02 GMT) Full text and rfc822 format available.

Message #41 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH v2 3/5] services: wpa-supplicant: Add 'wireless-daemon'
 provision.
Date: Sat, 24 May 2025 15:01:30 +0200
* gnu/services/networking.scm (wpa-supplicant-configuration):
[requirement]: Deprecate, [shepherd-requirement]: New field,
[shepherd-provision]: Extract to a field. Add 'wireless-daemon to it.
* doc/guix.texi (Networking Setup): Document it.

Change-Id: Icc6fdd695e6e96ef168a085524989da639f77cd3
---
 doc/guix.texi               |  5 +++-
 gnu/services/networking.scm | 52 ++++++++++++++++++++++++-------------
 2 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 502482b754..a3956172bc 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22383,9 +22383,12 @@ Networking Setup
 @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
 The WPA Supplicant package to use.
 
-@item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
+@item @code{shepherd-requirement} (default: @code{(user-processes loopback syslogd)}
 List of services that should be started before WPA Supplicant starts.
 
+@item @code{shepherd-provision} (default: @code{(wpa-supplicant wireless-daemon)}) (type: list-of-symbols)
+The name(s) of the service.
+
 @item @code{dbus?} (default: @code{#t})
 Whether to listen for requests on D-Bus.
 
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 4cb7313808..582c0edd32 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -226,6 +226,8 @@ (define-module (gnu services networking)
             wpa-supplicant-configuration?
             wpa-supplicant-configuration-wpa-supplicant
             wpa-supplicant-configuration-requirement
+            wpa-supplicant-configuration-shepherd-requirement
+            wpa-supplicant-configuration-shepherd-provision
             wpa-supplicant-configuration-pid-file
             wpa-supplicant-configuration-dbus?
             wpa-supplicant-configuration-interface
@@ -2022,34 +2024,48 @@ (define usb-modeswitch-service-type
 ;;; WPA supplicant
 ;;;
 
+(define-with-syntax-properties (warn-deprecated-wpa-supplicant-requirement
+                                (value properties))
+  (unless (unspecified? value)
+    (warning (source-properties->location properties)
+             (G_ "the 'requirement' field is deprecated, please use \
+'shepherd-requirement' field instead~%")))
+  value)
+
 (define-record-type* <wpa-supplicant-configuration>
   wpa-supplicant-configuration make-wpa-supplicant-configuration
   wpa-supplicant-configuration?
-  (wpa-supplicant     wpa-supplicant-configuration-wpa-supplicant ;file-like
-                      (default wpa-supplicant))
-  (requirement        wpa-supplicant-configuration-requirement    ;list of symbols
-                      (default '(user-processes loopback syslogd)))
-  (pid-file           wpa-supplicant-configuration-pid-file       ;string
-                      (default "/var/run/wpa_supplicant.pid"))
-  (dbus?              wpa-supplicant-configuration-dbus?          ;Boolean
-                      (default #t))
-  (interface          wpa-supplicant-configuration-interface      ;#f | string
-                      (default #f))
-  (config-file        wpa-supplicant-configuration-config-file    ;#f | <file-like>
-                      (default #f))
-  (extra-options      wpa-supplicant-configuration-extra-options  ;list of strings
-                      (default '())))
+  (wpa-supplicant        wpa-supplicant-configuration-wpa-supplicant ;file-like
+                         (default wpa-supplicant))
+  (requirement           wpa-supplicant-configuration-requirement ;list of symbols
+                         (sanitize warn-deprecated-wpa-supplicant-requirement)
+                         (default *unspecified*))
+  (pid-file              wpa-supplicant-configuration-pid-file ;string
+                         (default "/var/run/wpa_supplicant.pid"))
+  (dbus?                 wpa-supplicant-configuration-dbus? ;Boolean
+                         (default #t))
+  (interface             wpa-supplicant-configuration-interface ;#f | string
+                         (default #f))
+  (config-file           wpa-supplicant-configuration-config-file ;#f | <file-like>
+                         (default #f))
+  (extra-options         wpa-supplicant-configuration-extra-options ;list of strings
+                         (default '()))
+  (shepherd-provision    wpa-supplicant-configuration-shepherd-provision    ;list of symbols
+                         (default '(wpa-supplicant wireless-daemon)))
+  (shepherd-requirement  wpa-supplicant-configuration-shepherd-requirement  ;list of symbols
+                         (default '(user-processes loopback syslogd))))
 
 (define (wpa-supplicant-shepherd-service config)
   (match-record config <wpa-supplicant-configuration>
     (wpa-supplicant requirement pid-file dbus?
+                    shepherd-requirement shepherd-provision
                     interface config-file extra-options)
     (list (shepherd-service
            (documentation "Run the WPA supplicant daemon")
-           (provision '(wpa-supplicant))
-           (requirement (if dbus?
-                            (cons 'dbus-system requirement)
-                            requirement))
+           (provision shepherd-provision)
+           (requirement `(,@(if dbus? '(dbus-system) '())
+                          ,@(or (if (unspecified? requirement) #f requirement)
+                                shepherd-requirement)))
            (start #~(make-forkexec-constructor
                      (list (string-append #$wpa-supplicant
                                           "/sbin/wpa_supplicant")
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, ludo <at> gnu.org, gabriel <at> erlikon.ch, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Sat, 24 May 2025 13:03:02 GMT) Full text and rfc822 format available.

Message #44 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH v2 4/5] services: network-manager: Require wireless-daemon.
Date: Sat, 24 May 2025 15:01:31 +0200
* gnu/services/networking.scm
(<network-manager-configuration>)[shepherd-requirement]:
Replace wpa-supplicant with wireless-daemon.
* doc/guix.texi (Networking Setup): Adjust.

Change-Id: Id1a51429ccb6ea24839fc2aacd051a3ffe91c33c
---
 doc/guix.texi               | 11 ++++++-----
 gnu/services/networking.scm |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a3956172bc..a9c815c35c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22047,11 +22047,12 @@ Networking Setup
 @item @code{network-manager} (default: @code{network-manager})
 The NetworkManager package to use.
 
-@item @code{shepherd-requirement} (default: @code{'(wpa-supplicant)})
-This option can be used to provide a list of symbols naming Shepherd services
-that this service will depend on, such as @code{'wpa-supplicant} or
-@code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
-networks.
+@item @code{shepherd-requirement} (default: @code{'(wireless-daemon)})
+This option can be used to provide a list of symbols naming Shepherd
+services that this service will depend on. The default @code{'wireless-daemon}
+is provided by @code{'wpa-supplicant-service-type} and @code{'iwd-service-type}.
+Make sure you have one of these configured. Note, that @code{%desktop-services}
+already include @code{wpa-supplicant-service-type}.
 
 @item @code{dns} (default: @code{"default"})
 Processing mode for DNS, which affects how NetworkManager uses the
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 582c0edd32..900790ef2d 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -1417,7 +1417,7 @@ (define-record-type* <network-manager-configuration>
   (network-manager network-manager-configuration-network-manager
                    (default network-manager))
   (shepherd-requirement network-manager-configuration-shepherd-requirement
-                        (default '(wpa-supplicant)))
+                        (default '(wireless-daemon)))
   (dns network-manager-configuration-dns
        (default "default"))
   (vpn-plugins network-manager-configuration-vpn-plugins ;list of file-like
-- 
2.49.0





Information forwarded to sarg <at> sarg.org.ru, ludo <at> gnu.org, gabriel <at> erlikon.ch, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78546; Package guix-patches. (Sat, 24 May 2025 13:03:03 GMT) Full text and rfc822 format available.

Message #47 received at 78546 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78546 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH v2 5/5] services: networking: Add iwd-service-type.
Date: Sat, 24 May 2025 15:01:32 +0200
* gnu/services/networking.scm (iwd-service-type): New service type.
(iwd-configuration), (iwd-settings), (iwd-scan-settings),
(iwd-general-settings), (iwd-network-settings): New configuration types.
* doc/guix.texi (Networking setup): Document it.

Change-Id: I852115b9c6768b3ec4eedb34a7f9e66438bd1429
---
 doc/guix.texi               | 162 +++++++++++++++++++++++
 gnu/services/networking.scm | 249 ++++++++++++++++++++++++++++++++++++
 2 files changed, 411 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index a9c815c35c..4d1b6372df 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22408,6 +22408,168 @@ Networking Setup
 @end table
 @end deftp
 
+@cindex IWD
+@defvar iwd-service-type
+This is the service type to run @acronyml{IWD,Internet Wireless Daemon},
+a wireless daemon required to authenticate against encrypted WiFi
+networks.
+@end defvar
+
+@quotation Warning
+By default @code{iwd} removes and re-creates interfaces it manages.  It
+doesn't play nicely with @code{dhcp-client-service-type} that enumerates
+wireless interfaces before starting the Shepherd service.  Use either
+@code{dhcpcd-service-type} or the @code{iwd}'s built-in DHCP client (see
+@code{enable-network-configuration} option below).
+@end quotation
+
+@quotation Warning
+@code{iwd-service-type} conflicts with @code{wpa-supplicant-service-type}.
+Make sure only one is configured.
+@end quotation
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-configuration
+Available @code{iwd-configuration} fields are:
+
+@table @asis
+@item @code{iwd} (default: @code{iwd}) (type: file-like)
+The IWD package to use.
+
+@item @code{interfaces} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will control.
+
+@item @code{ignored-interfaces} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will not manage.
+
+@item @code{phys} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will control.
+
+@item @code{ignored-phys} (default: @code{()}) (type: list-of-strings)
+If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will not manage.
+
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+Shepherd requirements the service should depend on.
+
+@item @code{shepherd-provision} (default: @code{(iwd wireless-daemon)}) (type: list-of-symbols)
+The name(s) of the service.
+
+@item @code{config} (type: iwd-settings)
+Configuration settings.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-settings
+Available @code{iwd-settings} fields are:
+
+@table @asis
+@item @code{general} (type: iwd-general-settings)
+General settings.
+
+@item @code{network} (type: maybe-iwd-network-settings)
+Network settings.
+
+@item @code{scan} (type: maybe-iwd-scan-settings)
+Scan settings.
+
+@item @code{extra-config} (default: @code{()}) (type: list-of-strings)
+Extra configuration values to append to the IWD configuration file.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-general-settings
+Available @code{iwd-general-settings} fields are:
+
+@table @asis
+@item @code{enable-network-configuration?} (default: @code{#f}) (type: boolean)
+Setting this option to true enables @code{iwd} to configure the network
+interfaces with the IP addresses.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the General settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-network-settings
+Available @code{iwd-network-settings} fields are:
+
+@table @asis
+@item @code{enable-ipv6?} (default: @code{#t}) (type: boolean)
+Sets the global default that tells @code{iwd} whether it should
+configure IPv6 addresses and routes
+
+@item @code{name-resolving-service} (default: @code{none}) (type: resolving-service)
+Configures a DNS resolution method used by the system.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the Network settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
+@c %start of fragment
+
+@deftp {Data Type} iwd-scan-settings
+Available @code{iwd-scan-settings} fields are:
+
+@table @asis
+@item @code{disable-periodic-scan?} (default: @code{#f}) (type: boolean)
+Setting this option to @code{#t} will prevent @code{iwd} from issuing
+the periodic scans for the available networks while disconnected.
+
+@item @code{initial-periodic-scan-interval} (default: @code{10}) (type: number)
+The initial periodic scan interval upon disconnect (in seconds).
+
+@item @code{maximum-periodic-scan-interval} (default: @code{300}) (type: number)
+The maximum periodic scan interval (in seconds).
+
+@item @code{disable-roaming-scan?} (default: @code{#f}) (type: boolean)
+Setting this option to @code{#t} will prevent @code{iwd} from trying to
+scan when roaming decisions are activated.
+
+@item @code{extra-options} (default: @code{()}) (type: alist)
+An association list of option symbols/strings to string values to be
+appended to the Scan settings group.
+
+@end table
+
+@end deftp
+
+
+@c %end of fragment
+
 @cindex ModemManager
 Some networking devices such as modems require special care, and this is
 what the services below focus on.
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 900790ef2d..0a114d2a18 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -41,6 +41,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu services networking)
+  #:use-module (gnu home services utils)
   #:use-module (gnu services)
   #:use-module (gnu services base)
   #:use-module (gnu services configuration)
@@ -56,6 +57,7 @@ (define-module (gnu services networking)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages cluster)
   #:use-module (gnu packages connman)
+  #:use-module (gnu packages dns)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages tor)
@@ -80,6 +82,7 @@ (define-module (gnu services networking)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-43)
+  #:use-module ((ice-9 curried-definitions) #:select (define))
   #:use-module (ice-9 match)
   #:use-module (ice-9 string-fun)
   #:use-module (json)
@@ -235,6 +238,21 @@ (define-module (gnu services networking)
             wpa-supplicant-configuration-extra-options
             wpa-supplicant-service-type
 
+            iwd-configuration
+            iwd-configuration-config
+            iwd-configuration-ignored-interfaces
+            iwd-configuration-ignored-phys
+            iwd-configuration-interfaces
+            iwd-configuration-iwd
+            iwd-configuration-phys
+            iwd-configuration-shepherd-provision
+            iwd-configuration-shepherd-requirement
+            iwd-service-type
+            iwd-general-settings
+            iwd-network-settings
+            iwd-scan-settings
+            iwd-settings
+
             hostapd-configuration
             hostapd-configuration?
             hostapd-configuration-package
@@ -2099,6 +2117,237 @@ (define wpa-supplicant-service-type
 implements authentication, key negotiation and more for wireless networks.")
                   (default-value (wpa-supplicant-configuration)))))
 
+
+;;;
+;;; IWD
+;;;
+(define (iwd-uglify-field-name name)
+  (object->camel-case-string name 'upper))
+
+(define (iwd-serialize-base field-name val)
+  (format #f "~a=~a\n" field-name val))
+
+(define (iwd-serialize-field field-name val)
+  (iwd-serialize-base (iwd-uglify-field-name field-name) val))
+
+(define iwd-serialize-number iwd-serialize-field)
+
+(define (iwd-serialize-boolean field-name value)
+  (iwd-serialize-field
+   (string-trim-right (symbol->string field-name) #\?)
+   (if value "true" "false")))
+
+(define (iwd-serialize-alist field-name value)
+  (if (null? value)
+      ""
+      #~(string-append #$@(generic-serialize-alist list
+                                                   iwd-serialize-base
+                                                   value))))
+
+(define-enumerated-field-type resolving-service
+  (none systemd resolvconf)
+  (prefix iwd-))
+
+(define-configuration iwd-general-settings
+  (enable-network-configuration?
+   (boolean #f)
+   "Setting this option to true enables @code{iwd} to configure the network
+interfaces with the IP addresses.")
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the General settings group.")
+
+  (prefix iwd-))
+
+(define-configuration iwd-network-settings
+  (enable-ipv6?
+   (boolean #t)
+   "Sets the global default that tells @code{iwd} whether it should configure
+IPv6 addresses and routes")
+
+  (name-resolving-service
+   (resolving-service 'none)
+   "Configures a DNS resolution method used by the system.")
+
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the Network settings group.")
+
+  (prefix iwd-))
+
+(define-configuration iwd-scan-settings
+  (disable-periodic-scan?
+   (boolean #f)
+   "Setting this option to @code{#t} will prevent @code{iwd} from issuing the
+periodic scans for the available networks while disconnected.")
+
+  (initial-periodic-scan-interval
+   (number 10)
+   "The initial periodic scan interval upon disconnect (in seconds).")
+
+  (maximum-periodic-scan-interval
+   (number 300)
+   "The maximum periodic scan interval (in seconds).")
+
+  (disable-roaming-scan?
+   (boolean #f)
+   "Setting this option to @code{#t} will prevent @code{iwd} from trying to scan
+when roaming decisions are activated.")
+
+  (extra-options
+   (alist '())
+   "An association list of option symbols/strings to string values to be
+appended to the Scan settings group.")
+
+  (prefix iwd-))
+
+(define-maybe iwd-network-settings)
+(define-maybe iwd-scan-settings)
+
+(define ((iwd-serialize-config-section fields) name cfg)
+  #~(format #f "[~a]\n~a\n"
+            #$(string-upcase (object->string name) 0 1)
+            #$(serialize-configuration cfg fields)))
+
+(define serialize-iwd-network-settings
+  (iwd-serialize-config-section iwd-network-settings-fields))
+
+(define serialize-iwd-scan-settings
+  (iwd-serialize-config-section iwd-scan-settings-fields))
+
+(define serialize-iwd-general-settings
+  (iwd-serialize-config-section iwd-general-settings-fields))
+
+(define-configuration iwd-settings
+  (general
+   (iwd-general-settings (iwd-general-settings))
+   "General settings.")
+
+  (network
+   maybe-iwd-network-settings
+   "Network settings.")
+
+  (scan
+   maybe-iwd-scan-settings
+   "Scan settings.")
+
+  (extra-config
+   (list-of-strings '())
+   "Extra configuration values to append to the IWD configuration file."
+   (serializer (lambda (_ value) (string-join value "\n" 'suffix)))))
+
+(define-configuration/no-serialization iwd-configuration
+  (iwd
+   (file-like iwd)
+   "The IWD package to use.")
+
+  (interfaces
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will control.")
+
+  (ignored-interfaces
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+interfaces that IWD will not manage.")
+
+  (phys
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will control.")
+
+  (ignored-phys
+   (list-of-strings '())
+   "If this is set, it must specify @dfn{glob patterns} matching network
+PHYs names that IWD will not manage.")
+
+  (shepherd-requirement
+   (list-of-symbols '())
+   "Shepherd requirements the service should depend on.")
+
+  (shepherd-provision
+   (list-of-symbols '(iwd wireless-daemon))
+   "The name(s) of the service.")
+
+  (config
+   (iwd-settings (iwd-settings))
+   "Configuration settings."))
+
+(define (iwd-generate-documentation)
+  (configuration->documentation 'iwd-configuration)
+  (configuration->documentation 'iwd-settings)
+  (configuration->documentation 'iwd-general-settings)
+  (configuration->documentation 'iwd-network-settings)
+  (configuration->documentation 'iwd-scan-settings))
+
+(define (iwd-config-file config)
+  "Return an IWD configuration file."
+  (mixed-text-file "main.conf"
+                   (serialize-configuration
+                    (iwd-configuration-config config)
+                    iwd-settings-fields)))
+
+(define (iwd-environment config)
+  (let ((resolver
+         (and=> (iwd-settings-network (iwd-configuration-config config))
+                iwd-network-settings-name-resolving-service)))
+
+    (if (eq? resolver 'resolvconf)
+        #~(list (string-append "PATH=" #$openresolv "/sbin"))
+        '())))
+
+(define (iwd-shepherd-service config)
+  (match-record config <iwd-configuration>
+                (iwd interfaces ignored-interfaces
+                     phys ignored-phys
+                     shepherd-requirement shepherd-provision)
+
+    (list (shepherd-service
+           (documentation "Run Internet Wireless Daemon")
+           (provision shepherd-provision)
+           (requirement `(user-processes dbus-system loopback ,@shepherd-requirement))
+           (start #~(make-forkexec-constructor
+                     (list (string-append #$iwd "/libexec/iwd")
+                           "--logger=syslog"
+                           #$@(if (null? interfaces) '()
+                                  (list (string-append "--interfaces="
+                                                       (string-join interfaces ","))))
+                           #$@(if (null? ignored-interfaces) '()
+                                  (list (string-append "--nointerfaces="
+                                                       (string-join ignored-interfaces ","))))
+                           #$@(if (null? phys) '()
+                                  (list (string-append "--phys="
+                                                       (string-join phys ","))))
+                           #$@(if (null? ignored-phys) '()
+                                  (list (string-append "--nophys="
+                                                       (string-join ignored-phys ",")))))
+
+                     #:environment-variables
+                     #$(iwd-environment config)))
+           (stop #~(make-kill-destructor))))))
+
+(define (iwd-etc-service config)
+  `(("iwd/main.conf" ,(iwd-config-file config))))
+
+(define iwd-service-type
+  (let ((add-iwd-package (compose list iwd-configuration-iwd)))
+    (service-type (name 'iwd)
+                  (extensions
+                   (list (service-extension shepherd-root-service-type
+                                            iwd-shepherd-service)
+                         (service-extension etc-service-type
+                                            iwd-etc-service)
+                         (service-extension dbus-root-service-type
+                                            add-iwd-package)
+                         (service-extension profile-service-type
+                                            add-iwd-package)))
+                  (default-value (iwd-configuration))
+                  (description
+                   "Run @url{https://iwd.wiki.kernel.org/,Iwd},
+a network connection manager."))))
+
 
 ;;;
 ;;; Hostapd.
-- 
2.49.0





bug closed, send any further explanations to 78546 <at> debbugs.gnu.org and Sergey Trofimov <sarg <at> sarg.org.ru> Request was from Sergey Trofimov <sarg <at> sarg.org.ru> to control <at> debbugs.gnu.org. (Fri, 06 Jun 2025 08:01:02 GMT) Full text and rfc822 format available.

This bug report was last modified 9 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.