[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
14/15: services: mpd: Do not hardcode environment variables.
From: |
guix-commits |
Subject: |
14/15: services: mpd: Do not hardcode environment variables. |
Date: |
Sun, 5 Feb 2023 01:08:50 -0500 (EST) |
lilyp pushed a commit to branch master
in repository guix.
commit 637a9c3b264fe8eb76b6ed9f104b635d95632be6
Author: Bruno Victal <mirai@makinata.eu>
AuthorDate: Thu Feb 2 20:07:38 2023 +0000
services: mpd: Do not hardcode environment variables.
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.
Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
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 cd18959db0..e7d56f2504 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33199,6 +33199,9 @@ The group to run mpd as.
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 2bb8f66c96..3cbe21f23e 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -316,6 +316,11 @@ to be appended to the audio output 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
@@ -464,7 +469,8 @@ appended to the configuration.")
(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)")
@@ -489,11 +495,7 @@ appended to the configuration.")
(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)
- branch master updated (f57e20d728 -> 139c9a53cb), guix-commits, 2023/02/05
- 01/15: gnu: Add guile-simple-iterators., guix-commits, 2023/02/05
- 02/15: gnu: komikku: Update to 1.10.1., guix-commits, 2023/02/05
- 06/15: gnu: Rename 'samba/fixed' to 'samba/pinned'., guix-commits, 2023/02/05
- 09/15: gnu: wine-minimal: Make the parent of wine so phases can be shared., guix-commits, 2023/02/05
- 11/15: gnu: wine-minimal: Build more reproducibly., guix-commits, 2023/02/05
- 14/15: services: mpd: Do not hardcode environment variables.,
guix-commits <=
- 03/15: gnu: Rename 'git-minimal/fixed' to 'git-minimal/pinned'., guix-commits, 2023/02/05
- 04/15: gnu: Rename 'libnftnl/fixed' to 'libnftnl/pinned'., guix-commits, 2023/02/05
- 05/15: gnu: Rename 'guile-3.0/fixed' to 'guile-3.0/pinned'., guix-commits, 2023/02/05
- 08/15: gnu: wine-staging: Update to 8.0., guix-commits, 2023/02/05
- 10/15: gnu: wine64: Share phases with parent wine package., guix-commits, 2023/02/05
- 12/15: services: mpd: Rewrite using 'define-configuration'., guix-commits, 2023/02/05
- 13/15: services: mpd: Refactor MPD service., guix-commits, 2023/02/05
- 07/15: gnu: wine: Update to 8.0., guix-commits, 2023/02/05
- 15/15: services: Add mympd-service-type., guix-commits, 2023/02/05