Subject: bug#63082: [PATCH v2 13/16] services: mpd: Obsolete 'environment-variables' field.

From: Maxim Cournoyer <[email-masked]>
Date: Sat, 29 Apr 2023 13:21:50 -0400

Rationale: Services can be extended via the simple-service mechanism instead
of having to expose fields on service configurations that are not directly
connected to the service's configuration.

* gnu/services/audio.scm (mpd-environment-variables-sanitizer): New sanitizer.
(mpd-configuration): Use it.
(mpd-shepherd-service): Hard code the useful environment variables inside the
Shepherd service.
---
 doc/guix.texi          |  4 ++--
 gnu/services/audio.scm | 17 ++++++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3de7405318..148ca88633 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33578,8 +33578,8 @@ Audio Services
 This is a list of symbols naming Shepherd services that this service
 will depend on.
 
-@item @code{environment-variables} (default: @code{("PULSE_CLIENTCONFIG=/etc/pulse/client.conf" "PULSE_CONFIG=/etc/pulse/daemon.conf")}) (type: list-of-strings)
-A list of strings specifying environment variables.
+@item @code{environment-variables} (default: @code{#f}) (type: boolean)
+Obsolete.  Do not use.
 
 @item @code{log-file} (type: maybe-string)
 The location of the log file.  Unless specified, logs are sent to the
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 1e0a8b7f9e..dca2e8e5f6 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -249,7 +249,11 @@ (define (mpd-log-file-sanitizer value)
      value)
     (_ (configuration-field-error #f 'log-file value))))
 
-;;;
+(define (mpd-environment-variables-sanitizer value)
+  (when value
+    (warning (G_ "'environment-variables' in <mpd-configuration> is obsolete;\
+ ignoring~%")))
+  #f)
 
 ;; Generic MPD plugin record, lists only the most prevalent fields.
 (define-configuration mpd-plugin
@@ -423,9 +427,9 @@ (define-configuration mpd-configuration
    empty-serializer)
 
   (environment-variables
-   (list-of-strings '("PULSE_CLIENTCONFIG=/etc/pulse/client.conf"
-                      "PULSE_CONFIG=/etc/pulse/daemon.conf"))
-   "A list of strings specifying environment variables."
+   (boolean #f)
+   "Obsolete.  Do not use."
+   (sanitizer mpd-environment-variables-sanitizer)
    empty-serializer)
 
   (log-file
@@ -626,7 +630,10 @@ (define (mpd-shepherd-service config)
               (make-forkexec-constructor
                (list #$(file-append package "/bin/mpd") "--no-daemon"
                      #$config-file)
-               #:environment-variables '#$environment-variables
+               #:environment-variables
+               ;; Use the system-configured pulse configuration.
+               (list "PULSE_CLIENTCONFIG=/etc/pulse/client.conf"
+                     "PULSE_CONFIG=/etc/pulse/daemon.conf")
                #:user #$username
                #:group #$(user-account-group user)
                #:supplementary-groups
-- 
2.39.2