unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Bruno Victal <mirai@makinata.eu>
To: 59866@debbugs.gnu.org
Cc: Bruno Victal <mirai@makinata.eu>, liliana.prikler@gmail.com
Subject: [bug#59866] [PATCH v6 3/3] services: mpd: Do not hardcode environment variables.
Date: Thu,  2 Feb 2023 20:07:38 +0000	[thread overview]
Message-ID: <6b51304098d50a01c207abddb3b02ba863034e56.1675367583.git.mirai@makinata.eu> (raw)
In-Reply-To: <23b0f83d1fd58fce9262d0b281b34e9678e21471.1675367583.git.mirai@makinata.eu>

Services should not expect for XDG_RUNTIME_DIR to be set.
Inferring from the past comment, this seemed to resolve an issue when
the service was launched with an _interactive_ user-account,
which tends to have this variable set by the login-manager.

This is not the case for system accounts and setting this variable
results in PulseAudio (launched by the same system user) failing to start
since it attempts to use a nonexistent directory.

Ideally, this service should have a home-service counterpart but the old
behavior can be emulated by setting the environment-variables field to:

(environment-variables
  (list
    (string-append "XDG_RUNTIME_DIR=/run/user/"
                   (number->string (passwd:uid (getpwnam "myuser"))))))

* gnu/services/audio.scm
(mpd-configuration)[environment-variables]: New field.
(mpd-shepherd-service)[start]: Use new field.
* doc/guix.texi (Audio Services)[Music Player Daemon]: Document it.
---

Notable changes since v5:
  * NEW. Fixes PulseAudio issues resulting from hardcoded environment variables.

 doc/guix.texi          |  3 +++
 gnu/services/audio.scm | 14 ++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 8e220e0631..05c216bec4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33199,6 +33199,9 @@ Audio Services
 This is a list of symbols naming Shepherd services that this service
 will depend on.
 
+@item @code{environment-variables} (default: @code{()}) (type: list-of-string)
+A list of strings specifying environment variables.
+
 @item @code{log-file} (default: @code{"/var/log/mpd/log"}) (type: maybe-string)
 The location of the log file.  Set to @code{syslog} to use the local
 syslog daemon or @code{%unset-value} to omit this directive from the
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 7168320635..96b27660e5 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -316,6 +316,11 @@ (define-configuration mpd-configuration
 will depend on."
    empty-serializer)
 
+  (environment-variables
+   (list-of-string '())
+   "A list of strings specifying environment variables."
+   empty-serializer)
+
   (log-file
    (maybe-string "/var/log/mpd/log")
    "The location of the log file. Set to @code{syslog} to use the
@@ -465,7 +470,8 @@ (define (mpd-log-rotation config)
 (define (mpd-shepherd-service config)
   (match-record config <mpd-configuration> (user package shepherd-requirement
                                             log-file playlist-directory
-                                            db-file state-file sticker-file)
+                                            db-file state-file sticker-file
+                                            environment-variables)
     (let* ((config-file (mpd-serialize-configuration config)))
       (shepherd-service
        (documentation "Run the MPD (Music Player Daemon)")
@@ -490,11 +496,7 @@ (define (mpd-shepherd-service config)
                    (list #$(file-append package "/bin/mpd")
                          "--no-daemon"
                          #$config-file)
-                   #:environment-variables
-                   ;; Required to detect PulseAudio when run under a user account.
-                   (list (string-append
-                          "XDG_RUNTIME_DIR=/run/user/"
-                          (number->string (passwd:uid (getpwnam #$user))))))))
+                   #:environment-variables '#$environment-variables)))
        (stop  #~(make-kill-destructor))
        (actions
         (list (shepherd-configuration-action config-file)
-- 
2.38.1





      parent reply	other threads:[~2023-02-02 20:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 23:22 [bug#59866] [PATCH 0/2] services: mpd: Refactor MPD service mirai
2022-12-06 23:25 ` [bug#59866] [PATCH 1/2] services: mpd: use 'define-configuration' mirai
2022-12-06 23:25 ` [bug#59866] [PATCH 2/2] services: mpd: Refactor MPD service mirai
2022-12-07  8:59 ` [bug#59866] [PATCH 0/2] " ( via Guix-patches via
2022-12-07 13:42   ` mirai
2022-12-07 13:43     ` ( via Guix-patches via
2022-12-07 18:27 ` Liliana Marie Prikler
2022-12-08 13:11   ` mirai
2022-12-08 13:35     ` [bug#54986] " Liliana Marie Prikler
2022-12-09 13:44       ` [bug#59866] " mirai
2022-12-09 19:22         ` Liliana Marie Prikler
2022-12-11 12:05           ` mirai
2022-12-08  0:59 ` [bug#59866] [PATCH v2] " mirai
2022-12-16 14:15 ` [bug#59866] [PATCH v3] " mirai
2022-12-21 14:15 ` [bug#59866] [PATCH v4 1/2] services: mpd: use 'define-configuration' mirai
2022-12-21 14:15   ` [bug#59866] [PATCH v4 2/2] services: mpd: Refactor MPD service mirai
2022-12-24 13:51 ` [bug#59866] [PATCH v5 1/2] services: mpd: rewrite using 'define-configuration' mirai
2022-12-24 13:51   ` [bug#59866] [PATCH v5 2/2] services: mpd: Refactor MPD service mirai
2022-12-24 14:11 ` [bug#59866] [PATCH v5.1] " mirai
2022-12-24 17:20   ` Liliana Marie Prikler
2022-12-24 19:17     ` mirai
2022-12-24 18:53 ` [bug#59866] [PATCH v5.2] " mirai
2023-01-03 14:43 ` [bug#59866] Pulseaudio woes mirai
2023-01-03 19:38   ` Liliana Marie Prikler
2023-02-02 20:07 ` [bug#59866] [PATCH v6 1/3] services: mpd: Rewrite using 'define-configuration' Bruno Victal
2023-02-02 20:07   ` [bug#59866] [PATCH v6 2/3] services: mpd: Refactor MPD service Bruno Victal
2023-02-02 21:08     ` Liliana Marie Prikler
2023-02-05  6:11       ` bug#59866: " Liliana Marie Prikler
2023-02-02 20:07   ` Bruno Victal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b51304098d50a01c207abddb3b02ba863034e56.1675367583.git.mirai@makinata.eu \
    --to=mirai@makinata.eu \
    --cc=59866@debbugs.gnu.org \
    --cc=liliana.prikler@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).