From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>,
Bruno Victal <mirai@makinata.eu>
Cc: 61570@debbugs.gnu.org
Subject: bug#61570: [PATCH] services: mpd: Use proper records.
Date: Sat, 18 Feb 2023 18:42:45 +0100 [thread overview]
Message-ID: <08fff16dcb7b4e2da9f4e2e05d010b1ea339b776.camel@gmail.com> (raw)
In-Reply-To: <87y1owsbab.fsf@gmail.com>
* gnu/services/audio.scm (mpd-user, mpd-group): New variables.
(mpd-serialize-user-account, mpd-serialize-user-group): New variables.
(mpd-configuration)[user]: Change type to user-account.
Change default accordingly.
[group]: Change type to user-group. Change default accordingly.
(mpd-shepherd-service, mpd-accounts): Adjust accordingly.
* doc/guix.texi ("Music Player Daemon") Adjust accordingly.
---
This patch fixes the issue of not being able to insert actual users and
groups into MPD service. Sadly, as define-configuration lacks proper
support for sanitizers, it's a backwards-incompatible change.
Perhaps it makes sense to extend define-configuration to support this
case?
Cheers
doc/guix.texi | 4 ++--
gnu/services/audio.scm | 41 +++++++++++++++++++++++++++--------------
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 44e2165a82..fa75eff62e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33181,10 +33181,10 @@ Data type representing the configuration of @command{mpd}.
@item @code{package} (default: @code{mpd}) (type: file-like)
The MPD package.
-@item @code{user} (default: @code{"mpd"}) (type: string)
+@item @code{user} (default: @code{(mpd-user "mpd")}) (type: user-account)
The user to run mpd as.
-@item @code{group} (default: @code{"mpd"}) (type: string)
+@item @code{group} (default: @code{(mpd-group "mpd")}) (type: user-group)
The group to run mpd as.
@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbol)
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index d55b804ba9..df9b0ac7f1 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -62,6 +62,9 @@ (define-module (gnu services audio)
mpd-partition-name
mpd-partition-extra-options
+ mpd-user
+ mpd-group
+
mpd-configuration
mpd-configuration?
mpd-configuration-package
@@ -328,6 +331,26 @@ (define list-of-mpd-plugin-or-output?
(list-of (lambda (x)
(or (mpd-output? x) (mpd-plugin? x)))))
+(define* (mpd-user #:optional (name "mpd") (group "mpd"))
+ (user-account
+ (name name)
+ (group group)
+ (system? #t)
+ (comment "Music Player Daemon (MPD) user")
+ (home-directory "/var/lib/mpd")
+ (shell (file-append shadow "/sbin/nologin"))))
+
+(define* (mpd-group #:optional (name "mpd"))
+ (user-group
+ (name name)
+ (system? #t)))
+
+(define (mpd-serialize-user-account field value)
+ (mpd-serialize-string field (user-account-name value)))
+
+(define (mpd-serialize-user-group field value)
+ (mpd-serialize-string field (user-group-name value)))
+
(define-configuration mpd-configuration
(package
(file-like mpd)
@@ -335,11 +358,11 @@ (define-configuration mpd-configuration
empty-serializer)
(user
- (string "mpd")
+ (user-account (mpd-user "mpd"))
"The user to run mpd as.")
(group
- (string "mpd")
+ (user-group (mpd-group "mpd"))
"The group to run mpd as.")
(shepherd-requirement
@@ -512,7 +535,7 @@ (define (mpd-shepherd-service config)
(and=> #$(maybe-value log-file)
(compose mkdir-p dirname))
- (let ((user (getpw #$user)))
+ (let ((user (getpw #$(user-account-name user))))
(for-each
(lambda (x)
(when (and x (not (file-exists? x)))
@@ -546,17 +569,7 @@ (define (mpd-shepherd-service config)
(define (mpd-accounts config)
(match-record config <mpd-configuration> (user group)
- (list (user-group
- (name group)
- (system? #t))
- (user-account
- (name user)
- (group 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"))))))
+ (list user group)))
(define mpd-service-type
(service-type
base-commit: 312f1f41d3f3f3e5d2c36ff46920c6dce1c21a17
--
2.39.1
next prev parent reply other threads:[~2023-02-18 18:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 12:53 bug#61570: Backward incompatible changes in mpd-service-type Maxim Cournoyer
2023-02-17 15:33 ` Bruno Victal
2023-02-17 18:06 ` Liliana Marie Prikler
2023-03-07 1:13 ` Maxim Cournoyer
2023-03-07 5:31 ` Liliana Marie Prikler
2023-02-18 17:42 ` Liliana Marie Prikler [this message]
2023-02-19 13:54 ` bug#61570: [PATCH] services: mpd: Use proper records Bruno Victal
2023-02-25 20:13 ` Maxim Cournoyer
2023-04-02 14:42 ` bug#61570: control-msg Bruno Victal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08fff16dcb7b4e2da9f4e2e05d010b1ea339b776.camel@gmail.com \
--to=liliana.prikler@gmail.com \
--cc=61570@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
--cc=mirai@makinata.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).