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>master
parent
5c5f0fc113
commit
637a9c3b26
|
@ -33199,6 +33199,9 @@ The group to run mpd as.
|
||||||
This is a list of symbols naming Shepherd services that this service
|
This is a list of symbols naming Shepherd services that this service
|
||||||
will depend on.
|
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)
|
@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
|
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
|
syslog daemon or @code{%unset-value} to omit this directive from the
|
||||||
|
|
|
@ -316,6 +316,11 @@ to be appended to the audio output configuration.")
|
||||||
will depend on."
|
will depend on."
|
||||||
empty-serializer)
|
empty-serializer)
|
||||||
|
|
||||||
|
(environment-variables
|
||||||
|
(list-of-string '())
|
||||||
|
"A list of strings specifying environment variables."
|
||||||
|
empty-serializer)
|
||||||
|
|
||||||
(log-file
|
(log-file
|
||||||
(maybe-string "/var/log/mpd/log")
|
(maybe-string "/var/log/mpd/log")
|
||||||
"The location of the log file. Set to @code{syslog} to use the
|
"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)
|
(define (mpd-shepherd-service config)
|
||||||
(match-record config <mpd-configuration> (user package shepherd-requirement
|
(match-record config <mpd-configuration> (user package shepherd-requirement
|
||||||
log-file playlist-directory
|
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)))
|
(let* ((config-file (mpd-serialize-configuration config)))
|
||||||
(shepherd-service
|
(shepherd-service
|
||||||
(documentation "Run the MPD (Music Player Daemon)")
|
(documentation "Run the MPD (Music Player Daemon)")
|
||||||
|
@ -489,11 +495,7 @@ appended to the configuration.")
|
||||||
(list #$(file-append package "/bin/mpd")
|
(list #$(file-append package "/bin/mpd")
|
||||||
"--no-daemon"
|
"--no-daemon"
|
||||||
#$config-file)
|
#$config-file)
|
||||||
#:environment-variables
|
#:environment-variables '#$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))))))))
|
|
||||||
(stop #~(make-kill-destructor))
|
(stop #~(make-kill-destructor))
|
||||||
(actions
|
(actions
|
||||||
(list (shepherd-configuration-action config-file)
|
(list (shepherd-configuration-action config-file)
|
||||||
|
|
Reference in New Issue