From e461d3b750080b03f3deea0b44b99c2fda9767ab Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 4 Dec 2020 09:43:17 +0100 Subject: service: Add shepherd discover action. * gnu/services/base.scm (shepherd-discover-action): New procedure, (guix-shepherd-service)[]: add it, []: honor it. * doc/guix.texi (Invoking guix-daemon): Document it. --- gnu/services/base.scm | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'gnu/services/base.scm') diff --git a/gnu/services/base.scm b/gnu/services/base.scm index d0d88e18a6..709d011f53 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1568,6 +1568,27 @@ (define shepherd-set-http-proxy-action (environ environment) #t))))) +(define shepherd-discover-action + ;; Shepherd action to enable or disable substitute servers discovery. + (shepherd-action + (name 'discover) + (documentation + "Enable or disable substitute servers discovery and restart the +'guix-daemon'.") + (procedure #~(lambda* (_ status) + (let ((environment (environ))) + (if (and status + (string=? status "on")) + (begin + (format #t "enable substitute servers discovery~%") + (setenv "discover" "on")) + (begin + (format #t "disable substitute servers discovery~%") + (unsetenv "discover"))) + (action 'guix-daemon 'restart) + (environ environment) + #t))))) + (define (guix-shepherd-service config) "Return a for the Guix daemon service with CONFIG." (match-record config @@ -1579,7 +1600,8 @@ (define (guix-shepherd-service config) (documentation "Run the Guix daemon.") (provision '(guix-daemon)) (requirement '(user-processes)) - (actions (list shepherd-set-http-proxy-action)) + (actions (list shepherd-set-http-proxy-action + shepherd-discover-action)) (modules '((srfi srfi-1) (ice-9 match) (gnu build shepherd))) @@ -1594,6 +1616,9 @@ (define proxy ;; the 'set-http-proxy' action. (or (getenv "http_proxy") #$http-proxy)) + (define discover? + (or (getenv "discover") #$discover?)) + ;; Start the guix-daemon from a container, when supported, ;; to solve an installation issue. See the comment below for ;; more details. @@ -1608,9 +1633,8 @@ (define proxy #$@(if use-substitutes? '() '("--no-substitutes")) - #$@(if discover? - '("--discover=yes") - '()) + (string-append "--discover=" + (if discover? "yes" "no")) "--substitute-urls" #$(string-join substitute-urls) #$@extra-options -- cgit v1.2.3