summary refs log tree commit diff
path: root/gnu/services/audio.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-11-29 14:19:55 +0000
committerChristopher Baines <mail@cbaines.net>2020-11-29 17:34:18 +0000
commitff01206345e2306cc633db48e0b29eab9077091a (patch)
tree25c7ee17005dadc9bf4fae3f0873e03a4704f782 /gnu/services/audio.scm
parented2545f0fa0e2ad99d5a0c45f532c539b299b9fb (diff)
parent7c2e67400ffaef8eb6f30ef7126c976ee3d7e36c (diff)
downloadguix-ff01206345e2306cc633db48e0b29eab9077091a.tar.gz
Merge remote-tracking branch 'origin/master' into core-updates
Diffstat (limited to 'gnu/services/audio.scm')
-rw-r--r--gnu/services/audio.scm33
1 files changed, 27 insertions, 6 deletions
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 37f2efa479..627b941871 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,8 @@
   #:use-module (guix gexp)
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (gnu packages admin)
   #:use-module (gnu packages mpd)
   #:use-module (guix records)
   #:use-module (ice-9 match)
@@ -135,19 +138,19 @@ audio_output {
 (define (mpd-shepherd-service config)
   (shepherd-service
    (documentation "Run the MPD (Music Player Daemon)")
+   (requirement '(user-processes))
    (provision '(mpd))
    (start #~(make-forkexec-constructor
              (list #$(file-append mpd "/bin/mpd")
                    "--no-daemon"
                    #$(mpd-config->file config))
-             #:pid-file #$(mpd-file-name config "pid")
              #:environment-variables
              ;; Required to detect PulseAudio when run under a user account.
-             '(#$(string-append
-                   "XDG_RUNTIME_DIR=/run/user/"
-                   (number->string
+             (list (string-append
+                    "XDG_RUNTIME_DIR=/run/user/"
+                    (number->string
                      (passwd:uid
-                       (getpwnam (mpd-configuration-user config))))))
+                      (getpwnam #$(mpd-configuration-user config))))))
              #:log-file #$(mpd-file-name config "log")))
    (stop  #~(make-kill-destructor))))
 
@@ -158,10 +161,26 @@ audio_output {
         (define %user
           (getpw #$(mpd-configuration-user config)))
 
-        (let ((directory #$(mpd-file-name config "")))
+        (let ((directory #$(mpd-file-name config ".mpd")))
           (mkdir-p directory)
           (chown directory (passwd:uid %user) (passwd:gid %user))))))
 
+
+(define %mpd-accounts
+  ;; Default account and group for MPD.
+  (list (user-group (name "mpd") (system? #t))
+        (user-account
+         (name "mpd")
+         (group "mpd")
+         (system? #t)
+         (comment "Music Player Daemon (MPD) user")
+
+         ;; Note: /var/run/mpd hosts one sub-directory per user, of which
+         ;; /var/run/mpd/mpd corresponds to the "mpd" user.
+         (home-directory "/var/run/mpd/mpd")
+
+         (shell (file-append shadow "/sbin/nologin")))))
+
 (define mpd-service-type
   (service-type
    (name 'mpd)
@@ -169,6 +188,8 @@ audio_output {
    (extensions
     (list (service-extension shepherd-root-service-type
                              (compose list mpd-shepherd-service))
+          (service-extension account-service-type
+                             (const %mpd-accounts))
           (service-extension activation-service-type
                              mpd-service-activation)))
    (default-value (mpd-configuration))))