aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/audio.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-04-27 20:16:22 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-07-26 10:40:16 -0400
commit776317e7072979ee87246c8382e63395d7cbfe4b (patch)
tree075b92b965501252fe5c3f0a61472552a7e1b22f /gnu/services/audio.scm
parent07bb69d52c23752149d99d1e3d090f7e58f47385 (diff)
downloadguix-776317e7072979ee87246c8382e63395d7cbfe4b.tar
guix-776317e7072979ee87246c8382e63395d7cbfe4b.tar.gz
services: mpd: Provision a default cache directory and set HOME.
Relates to <https://issues.guix.gnu.org/63082>. * gnu/services/audio.scm (mpd-shepherd-service): Create a default .cache directory. Use mkdir-p/perms and refactor loop. Set the HOME environment variables.
Diffstat (limited to 'gnu/services/audio.scm')
-rw-r--r--gnu/services/audio.scm57
1 files changed, 34 insertions, 23 deletions
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 3083090ad0..f01357ad8b 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -472,7 +472,8 @@ The available values, in decreasing order of verbosity, are: @code{verbose},
(db-file
maybe-string
- "The location of the music database.")
+ "The location of the music database. When left unspecified,
+@file{~/.cache/db} is used.")
(state-file
maybe-string
@@ -616,28 +617,38 @@ appended to the configuration.")
#~(begin
(use-modules (gnu build activation))
- (let ((user (getpw #$username)))
-
- (define (init-directory directory)
- (unless (file-exists? directory)
- (mkdir-p/perms directory user #o755)))
-
- (for-each
- init-directory
- '#$(map dirname
- ;; XXX: Delete the potential "syslog"
- ;; log-file value, which is not a directory.
- (delete "syslog"
- (filter-map maybe-value
- (list db-file
- log-file
- state-file
- sticker-file))))))
-
- (make-forkexec-constructor
- (list #$(file-append package "/bin/mpd") "--no-daemon"
- #$config-file)
- #:environment-variables '#$environment-variables))))
+ (let ((home #$(user-account-home-directory user)))
+ (let ((user (getpw #$username))
+ (default-cache-dir (string-append home "/.cache")))
+
+ (define (init-directory directory)
+ (unless (file-exists? directory)
+ (mkdir-p/perms directory user #o755)))
+
+ ;; Define a cache location that can be automatically used
+ ;; for the database file, in case it hasn't been explicitly
+ ;; specified.
+ (for-each
+ init-directory
+ (cons default-cache-dir
+ '#$(map dirname
+ ;; XXX: Delete the potential "syslog"
+ ;; log-file value, which is not a directory.
+ (delete "syslog"
+ (filter-map maybe-value
+ (list db-file
+ log-file
+ state-file
+ sticker-file)))))))
+
+ (make-forkexec-constructor
+ (list #$(file-append package "/bin/mpd") "--no-daemon"
+ #$config-file)
+ #:environment-variables
+ ;; Set HOME so MPD can infer default paths, such as
+ ;; for the database file.
+ (cons (string-append "HOME=" home)
+ '#$environment-variables))))))
(stop #~(make-kill-destructor))
(actions
(list (shepherd-configuration-action config-file)