Subject: [PATCH v2 3/5] services: wpa-supplicant: Add 'wireless-daemon' provision.

From: Sergey Trofimov <[email-masked]>
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