;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Peter Mikkelsen ;;; Copyright © 2019 Ricardo Wurmus ;;; Copyright © 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu services audio) #:use-module (guix gexp) #:use-module (gnu services) #:use-m
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/installer/utils.scm')
0 files changed, 0 insertions, 0 deletions
dir) ("db_file" ,mpd-configuration-db-file) ("state_file" ,mpd-configuration-state-file) ("sticker_file" ,mpd-configuration-sticker-file) ("port" ,mpd-configuration-port) ("bind_to_address" ,mpd-configuration-address)))))) (define (mpd-file-name config file) "Return a path in /var/run/mpd/ that is writable by @code{user} from @code{config}." (string-append "/var/run/mpd/" (mpd-configuration-user config) "/" file)) (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)) #: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 #$(mpd-configuration-user config)))))) #:log-file #$(mpd-file-name config "log"))) (stop #~(make-kill-destructor)))) (define (mpd-service-activation config) (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) (define %user (getpw #$(mpd-configuration-user config))) (let ((directory #$(mpd-file-name config ".mpd"))) (mkdir-p directory) (chown directory (passwd:uid %user) (passwd:gid %user)) ;; Make /var/run/mpd/USER user-owned as well. (chown (dirname 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) (description "Run the Music Player Daemon (MPD).") (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))))