From 0185b2f9b20565f2c1b9249e6f61d2a8497101cf Mon Sep 17 00:00:00 2001 From: Bruno Victal Date: Thu, 23 Mar 2023 15:02:14 +0000 Subject: services: mympd: Require 'syslog service when configured to log to syslog. * gnu/services/audio.scm (mympd-shepherd-service): Depend on 'syslog when configured to log to syslog. Signed-off-by: Maxim Cournoyer Modified-by: Maxim Cournoyer --- gnu/services/audio.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index d55b804ba9..848da651d7 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -752,7 +752,11 @@ prompting a pin from the user.") (let ((log-level* (format #f "MYMPD_LOGLEVEL=~a" log-level))) (shepherd-service (documentation "Run the myMPD daemon.") - (requirement `(loopback user-processes ,@shepherd-requirement)) + (requirement `(loopback user-processes + ,@(if (eq? log-to 'syslog) + '(syslog) + '()) + ,@shepherd-requirement)) (provision '(mympd)) (start #~(begin (let* ((pw (getpwnam #$user)) -- cgit 1.4.1 From 206446b4840279596b3b4522beaee43a3359133d Mon Sep 17 00:00:00 2001 From: Bruno Victal Date: Thu, 23 Mar 2023 15:02:13 +0000 Subject: services: audio: Remove redundant list-of-string? predicate. Use list-of-strings? predicate defined in (gnu services configuration). * gnu/services/audio.scm (list-of-string?): Remove predicate. (mpd-serialize-list-of-string): Rename procedure to ... (mpd-serialize-list-of-strings): ... this. (mpd-configuration)[environment-variables]: Switch to list-of-strings. [endpoints]: Switch to maybe-list-of-strings. (mympd-ip-acl)[allow, deny]: Switch to list-of-strings. (mympd-serialize-configuration): Rename serialize-list-of-string to serialize-list-of-strings. * doc/guix.texi (Audio Services): Update it. Signed-off-by: Maxim Cournoyer --- doc/guix.texi | 8 ++++---- gnu/services/audio.scm | 25 +++++++++++-------------- 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'gnu/services') diff --git a/doc/guix.texi b/doc/guix.texi index dfdb26103a..7c2feb1dd8 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33501,7 +33501,7 @@ The group to run mpd as. This is a list of symbols naming Shepherd services that this service will depend on. -@item @code{environment-variables} (default: @code{()}) (type: list-of-string) +@item @code{environment-variables} (default: @code{()}) (type: list-of-strings) A list of strings specifying environment variables. @item @code{log-file} (default: @code{"/var/log/mpd/log"}) (type: maybe-string) @@ -33532,7 +33532,7 @@ The location of the sticker database. @item @code{default-port} (default: @code{6600}) (type: maybe-integer) The default port to run mpd on. -@item @code{endpoints} (type: maybe-list-of-string) +@item @code{endpoints} (type: maybe-list-of-strings) The addresses that mpd will bind to. A port different from @var{default-port} may be specified, e.g. @code{localhost:6602} and IPv6 addresses must be enclosed in square brackets when a different port is used. @@ -33808,10 +33808,10 @@ Whether to preserve caches between service restarts. Available @code{mympd-ip-acl} fields are: @table @asis -@item @code{allow} (default: @code{()}) (type: list-of-string) +@item @code{allow} (default: @code{()}) (type: list-of-strings) Allowed IP addresses. -@item @code{deny} (default: @code{()}) (type: list-of-string) +@item @code{deny} (default: @code{()}) (type: list-of-strings) Disallowed IP addresses. @end table diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 848da651d7..73aae9dfcf 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2017 Peter Mikkelsen ;;; Copyright © 2019 Ricardo Wurmus ;;; Copyright © 2020 Ludovic Courtès -;;; Copyright © 2022 Bruno Victal +;;; Copyright © 2022⁠–⁠2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -137,9 +137,6 @@ str) #\-) "_"))) -(define list-of-string? - (list-of string?)) - (define list-of-symbol? (list-of symbol?)) @@ -159,11 +156,11 @@ (define mpd-serialize-string mpd-serialize-field) (define mpd-serialize-boolean mpd-serialize-field) -(define (mpd-serialize-list-of-string field-name value) +(define (mpd-serialize-list-of-strings field-name value) #~(string-append #$@(map (cut mpd-serialize-string field-name <>) value))) (define-maybe string (prefix mpd-)) -(define-maybe list-of-string (prefix mpd-)) +(define-maybe list-of-strings (prefix mpd-)) (define-maybe boolean (prefix mpd-)) ;;; TODO: Procedures for deprecated fields, to be removed. @@ -349,7 +346,7 @@ will depend on." empty-serializer) (environment-variables - (list-of-string '()) + (list-of-strings '()) "A list of strings specifying environment variables." empty-serializer) @@ -400,7 +397,7 @@ Available values: @code{notice}, @code{info}, @code{verbose}, "The default port to run mpd on.") (endpoints - maybe-list-of-string + maybe-list-of-strings "The addresses that mpd will bind to. A port different from @var{default-port} may be specified, e.g. @code{localhost:6602} and IPv6 addresses must be enclosed in square brackets when a different @@ -409,7 +406,7 @@ To use a Unix domain socket, an absolute path or a path starting with @code{~} can be specified here." (lambda (_ endpoints) (if (maybe-value-set? endpoints) - (mpd-serialize-list-of-string "bind_to_address" endpoints) + (mpd-serialize-list-of-strings "bind_to_address" endpoints) ""))) (address ; TODO: deprecated, remove later @@ -581,11 +578,11 @@ appended to the configuration.") (define-configuration/no-serialization mympd-ip-acl (allow - (list-of-string '()) + (list-of-strings '()) "Allowed IP addresses.") (deny - (list-of-string '()) + (list-of-strings '()) "Disallowed IP addresses.")) (define-maybe/no-serialization integer) @@ -707,12 +704,12 @@ prompting a pin from the user.") ((? string? val) val))) (define (ip-acl-serialize-configuration config) - (define (serialize-list-of-string prefix lst) + (define (serialize-list-of-strings prefix lst) (map (cut format #f "~a~a" prefix <>) lst)) (string-join (append - (serialize-list-of-string "+" (mympd-ip-acl-allow config)) - (serialize-list-of-string "-" (mympd-ip-acl-deny config))) ",")) + (serialize-list-of-strings "+" (mympd-ip-acl-allow config)) + (serialize-list-of-strings "-" (mympd-ip-acl-deny config))) ",")) ;; myMPD configuration fields are serialized as individual files under ;; /config/. -- cgit 1.4.1 From bc30a9ee889fb1b81c43a7f94ea4c2b95a15db75 Mon Sep 17 00:00:00 2001 From: Bruno Victal Date: Thu, 23 Mar 2023 15:02:16 +0000 Subject: services: mpd: Set PulseAudio-related variables. These variables are necessary for PulseAudio to work properly out-of-the-box for 'non-interactive' users. * doc/guix.texi (Audio Services): Update environment-variables field description for mpd-configuration data type. * gnu/services/audio.scm (mpd-configuration)[environment-variables]: Set PULSE_CLIENTCONFIG and PULSE_CONFIG environment variables to the system-wide PulseAudio configuration. Signed-off-by: Maxim Cournoyer --- doc/guix.texi | 2 +- gnu/services/audio.scm | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'gnu/services') diff --git a/doc/guix.texi b/doc/guix.texi index 7c2feb1dd8..3e335306f1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33501,7 +33501,7 @@ The group to run mpd as. This is a list of symbols naming Shepherd services that this service will depend on. -@item @code{environment-variables} (default: @code{()}) (type: list-of-strings) +@item @code{environment-variables} (default: @code{("PULSE_CLIENTCONFIG=/etc/pulse/client.conf" "PULSE_CONFIG=/etc/pulse/daemon.conf")}) (type: list-of-strings) A list of strings specifying environment variables. @item @code{log-file} (default: @code{"/var/log/mpd/log"}) (type: maybe-string) diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 73aae9dfcf..4885fb8424 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -346,7 +346,8 @@ will depend on." empty-serializer) (environment-variables - (list-of-strings '()) + (list-of-strings '("PULSE_CLIENTCONFIG=/etc/pulse/client.conf" + "PULSE_CONFIG=/etc/pulse/daemon.conf")) "A list of strings specifying environment variables." empty-serializer) -- cgit 1.4.1 From a7f118d062db4408b23505750c44a1f996496c43 Mon Sep 17 00:00:00 2001 From: r0man Date: Tue, 21 Mar 2023 20:11:41 +0100 Subject: services: xorg-wrapper: Support xorg server input rewriting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds support for proper xorg server input rewriting. It uses the lookup-package-direct-input procedure to configure the X server paths dynamically, instead of always using the hard coded package. Something like this is now possible: (define other-mesa (package-input-rewriting/spec `(("mesa" . ,(const other-mesa))))) (xorg-configuration (xorg-configuration (server (other-mesa xorg-server)))) Without this patch the X server would still be configured with mesa (causing version issues), and not with other-mesa (as per the input rewrite). * gnu/services/xorg.scm (xorg-configuration-server-package-path) (xorg-configuration-dri-driver-path, xorg-configuration-xkb-bin-dir) (xorg-configuration-xkb-dir): New procedures. (xorg-wrapper): Use them for dri and xkb paths. Signed-off-by: 宋文武 --- gnu/services/xorg.scm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index c4745cecf5..7295a45b59 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -358,6 +358,22 @@ in @var{modules}." files) #t)))) +(define (xorg-configuration-server-package-path config input path) + "Lookup the direct @var{input} in the xorg server package of @var{config} +and append @var{path} to it." + (let* ((server (xorg-configuration-server config)) + (package (lookup-package-direct-input server input))) + (when package (file-append package path)))) + +(define (xorg-configuration-dri-driver-path config) + (xorg-configuration-server-package-path config "mesa" "/lib/dri")) + +(define (xorg-configuration-xkb-bin-dir config) + (xorg-configuration-server-package-path config "xkbcomp" "/bin")) + +(define (xorg-configuration-xkb-dir config) + (xorg-configuration-server-package-path config "xkeyboard-config" "/share/X11/xkb")) + (define* (xorg-wrapper #:optional (config (xorg-configuration))) "Return a derivation that builds a script to start the X server with the given @var{config}. The resulting script should be used in place of @@ -365,12 +381,13 @@ given @var{config}. The resulting script should be used in place of (define exp ;; Write a small wrapper around the X server. #~(begin - (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri")) - (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin")) + (setenv "XORG_DRI_DRIVER_PATH" + #$(xorg-configuration-dri-driver-path config)) + (setenv "XKB_BINDIR" #$(xorg-configuration-xkb-bin-dir config)) (let ((X (string-append #$(xorg-configuration-server config) "/bin/X"))) (apply execl X X - "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb") + "-xkbdir" #$(xorg-configuration-xkb-dir config) "-config" #$(xorg-configuration->file config) "-configdir" #$(xorg-configuration-directory (xorg-configuration-modules config)) -- cgit 1.4.1 From 547965aa27b6a09cadf42130b7ec7db3f1aee61f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 24 Mar 2023 19:22:39 +0100 Subject: services: herd: Remove workaround for Shepherd < 0.5.0. * gnu/services/herd.scm (load-services/safe): Remove workaround for Shepherd < 0.5.0, released in 2018. --- gnu/services/herd.scm | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/herd.scm b/gnu/services/herd.scm index a7c845b4b0..e489ce2b9a 100644 --- a/gnu/services/herd.scm +++ b/gnu/services/herd.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016-2019, 2022 Ludovic Courtès +;;; Copyright © 2016-2019, 2022-2023 Ludovic Courtès ;;; Copyright © 2017, 2020 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. @@ -284,22 +284,12 @@ returns a shepherd object." (define (load-services/safe files) "This is like 'load-services', but make sure only the subset of FILES that -can be safely reloaded is actually reloaded. - -This is done to accommodate the Shepherd < 0.15.0 where services lacked the -'replacement' slot, and where 'register-services' would throw an exception -when passed a service with an already-registered name." - (eval-there `(let* ((services (map primitive-load ',files)) - (slots (map slot-definition-name - (class-slots ))) - (can-replace? (memq 'replacement slots))) - (define (registered? service) - (not (null? (lookup-services (canonical-name service))))) - - (apply register-services - (if can-replace? - services - (remove registered? services)))))) +can be safely reloaded is actually reloaded." + (eval-there `(let ((services (map primitive-load ',files))) + ;; Since version 0.5.0 of the Shepherd, registering a service + ;; that has the same name as an already-registered service + ;; makes it a "replacement" of that previous service. + (apply register-services services)))) (define* (start-service name #:optional (arguments '())) (invoke-action name 'start arguments -- cgit 1.4.1 From 384856c9fbe76d107107f49a575fc5c26e4e332e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 27 Mar 2023 09:42:20 +0200 Subject: services: syslog: Add 'configuration' action. * gnu/services/base.scm (syslog-service-type): Add 'actions' field. --- gnu/services/base.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 2c984a0747..5b0b3bb0ab 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1554,14 +1554,17 @@ Service Switch}, for an example." (shepherd-service-type 'syslog (lambda (config) + (define config-file + (syslog-configuration-config-file config)) + (shepherd-service (documentation "Run the syslog daemon (syslogd).") (provision '(syslogd)) (requirement '(user-processes)) + (actions (list (shepherd-configuration-action config-file))) (start #~(let ((spawn (make-forkexec-constructor (list #$(syslog-configuration-syslogd config) - "--rcfile" - #$(syslog-configuration-config-file config)) + "--rcfile" #$config-file) #:pid-file "/var/run/syslog.pid"))) (lambda () ;; Set the umask such that file permissions are #o640. -- cgit 1.4.1 From 82607c442bb1e88c70f899af07f1bb66b86e83c8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 27 Mar 2023 09:43:01 +0200 Subject: services: network-manager: Add 'configuration' action. * gnu/services/networking.scm (network-manager-shepherd-service): Add 'actions' field. --- gnu/services/networking.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 6ab313b97c..4d1d84788b 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013-2022 Ludovic Courtès +;;; Copyright © 2013-2023 Ludovic Courtès ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2016, 2018, 2020 Efraim Flashner ;;; Copyright © 2016 John Darrington @@ -1235,6 +1235,7 @@ project's documentation} for more information." ;; TODO: iwd? is deprecated and should be passed ;; with shepherd-requirement, remove later. ,@(if iwd? '(iwd) '()))) + (actions (list (shepherd-configuration-action conf))) (start #~(lambda _ (let ((pid -- cgit 1.4.1 From 3b9738aeac3dc0d1d2d119abd6370f569da5a1a6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 27 Mar 2023 09:43:43 +0200 Subject: services: ntpd: Add 'configuration' action. * gnu/services/networking.scm (ntp-shepherd-service): Add 'actions' field. --- gnu/services/networking.scm | 1 + 1 file changed, 1 insertion(+) (limited to 'gnu/services') diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 4d1d84788b..49f897d8cf 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -536,6 +536,7 @@ restrict source notrap nomodify noquery\n")) (provision '(ntpd)) (documentation "Run the Network Time Protocol (NTP) daemon.") (requirement '(user-processes networking)) + (actions (list (shepherd-configuration-action ntpd.conf))) (start #~(make-forkexec-constructor (list (string-append #$ntp "/bin/ntpd") "-n" "-c" #$ntpd.conf "-u" "ntpd" -- cgit 1.4.1 From f215d801277a60cc1d862ed59c179cb8a482ced5 Mon Sep 17 00:00:00 2001 From: Bruno Victal Date: Sun, 26 Mar 2023 16:17:22 +0100 Subject: services: fstrim: Fix schedule ungexp. Previously, only the first level of the list would be quoted, resulting in a schedule of the sort: '(next-second (range 0 60 30)) being incorrectly ungexp'd into: (list next-second (0 30)) * gnu/services/linux.scm (fstrim-mcron-job): Fix schedule ungexp. Signed-off-by: Maxim Cournoyer --- gnu/services/linux.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index d085b375a2..439848919d 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -234,7 +234,7 @@ more information)." ;; lists are ungexp'd correctly since @var{schedule} ;; can be either a procedure, a string or a list. #$(if (list? schedule) - `(list ,@schedule) + #~'(#$@schedule) schedule) (lambda () (system* #$(file-append package "/sbin/fstrim") -- cgit 1.4.1