Compare commits

...

3 Commits

Author SHA1 Message Date
Ian Eure
d780c4c1cc gnu: mpd-service-type: Add to the `audio' group.
Also, add `audio' to %mpd-user’s supplementary groups.  Without membership in
the `audio' group, MPD can’t access the sound hardware.

Fixes guix/guix#4136.

* gnu/services/audio.scm (%mpd-user): Add `audio' supplementary group.

Change-Id: I86c9990d516301c85eeee125bc9d0f44c73612c6
2025-11-08 23:40:45 -08:00
Ian Eure
701a498b42 gnu: mpd-service-type: Export users and groups.
* gnu/services/audio.scm (%mpd-user, %mpd-group): Export.

Change-Id: If5b5e5967c826d98fa17a574598f1d34559c57d5
2025-11-08 16:26:15 -08:00
Ian Eure
2be1e10e36 gnu: mpd-service-type: Remove `group' from configuration.
Use of the `group' option in the MPD configuration behaves oddly: when it’s
present, the MPD process runs without the supplementary groups the user is in.
Leaving it unspecified does the right thing, the process gets both the primary
and supplementary groups.  So, don’t serialize that option at all.

* gnu/services/audio.scm (%mpd-user): Use %mpd-group.
(mpd-configuration): Remove `group' field.
(mpd-configuration-group): Unexport.
(mpd-group-sanitizer): Delete variable.
(mpd-accounts): Create group if it’s `%mpd-group'.
(mpd-serialize-user-group): Remove.

Change-Id: I0c20c817ba7fd892c96497208ca5338088f74252
2025-11-08 16:26:14 -08:00

View File

@@ -39,7 +39,10 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-71)
#:export (mpd-output
#:export (%mpd-user
%mpd-group
mpd-output
mpd-output?
mpd-output-name
mpd-output-type
@@ -67,7 +70,6 @@
mpd-configuration?
mpd-configuration-package
mpd-configuration-user
mpd-configuration-group
mpd-configuration-shepherd-requirement
mpd-configuration-log-file
mpd-configuration-log-level
@@ -173,30 +175,26 @@
(define (mpd-serialize-user-account field-name value)
(mpd-serialize-string field-name (user-account-name value)))
(define (mpd-serialize-user-group field-name value)
(mpd-serialize-string field-name (user-group-name value)))
(define-maybe string (prefix mpd-))
(define-maybe list-of-strings (prefix mpd-))
(define-maybe boolean (prefix mpd-))
(define %mpd-user
(user-account
(name "mpd")
;; XXX: This is a place-holder to be lazily substituted in (…-accounts)
;; with the value from the 'group' field of <mpd-configuration>.
(group %lazy-group)
(system? #t)
(comment "Music Player Daemon (MPD) user")
;; MPD can use $HOME (or $XDG_CONFIG_HOME) to place its data.
(home-directory "/var/lib/mpd")
(shell (file-append shadow "/sbin/nologin"))))
(define %mpd-group
(user-group
(name "mpd")
(system? #t)))
(define %mpd-user
(user-account
(name "mpd")
(group (user-group-name %mpd-group))
(supplementary-groups '("audio"))
(system? #t)
(comment "Music Player Daemon (MPD) user")
;; MPD can use $HOME (or $XDG_CONFIG_HOME) to place its data.
(home-directory "/var/lib/mpd")
(shell (file-append shadow "/sbin/nologin"))))
;;; TODO: Procedures for deprecated fields, to be removed.
(define mpd-deprecated-fields '((music-dir . music-directory)
@@ -239,17 +237,6 @@ user-account instead~%"))
(else
(configuration-field-error #f 'user value))))
(define (mpd-group-sanitizer value)
(cond ((user-group? value) value)
((string? value)
(warning (G_ "string value for 'group' is deprecated, use \
user-group instead~%"))
(user-group
(inherit %mpd-group)
(name value)))
(else
(configuration-field-error #f 'group value))))
(define (mpd-log-file-sanitizer value)
;; XXX: While leaving the 'sys_log' option out of the mpd.conf file is
;; supposed to cause logging to happen via systemd (elogind provides a
@@ -417,11 +404,6 @@ to be appended to the audio output configuration.")
"The user to run mpd as."
(sanitizer mpd-user-sanitizer))
(group
(user-group %mpd-group)
"The group to run mpd as."
(sanitizer mpd-group-sanitizer))
(shepherd-requirement
(list-of-symbols '())
"This is a list of symbols naming Shepherd services that this service
@@ -650,12 +632,12 @@ appended to the configuration.")
(format #t "Service MPD is not running.")))))))))))
(define (mpd-accounts config)
(match-record config <mpd-configuration> (user group)
;; TODO: Deprecation code, to be removed.
(let ((user (if (eq? (user-account-group user) %lazy-group)
(set-user-group user group)
user)))
(list user group))))
(match-record config <mpd-configuration> (user)
`(,user
;; Create %mpd-group if that's what we're using.
,(when (string=? (user-group-name %mpd-group)
(user-account-group user))
%mpd-group))))
(define mpd-service-type
(service-type