diff options
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r-- | gnu/services/base.scm | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3fc4d5f885..945b546607 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1530,6 +1530,8 @@ archive' public keys, with GUIX." (default 0)) (log-compression guix-configuration-log-compression (default 'bzip2)) + (discover? guix-configuration-discover? + (default #f)) (extra-options guix-configuration-extra-options ;list of strings (default '())) (log-file guix-configuration-log-file ;string @@ -1566,18 +1568,40 @@ proxy of 'guix-daemon'...~%") (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 <shepherd-service> for the Guix daemon service with CONFIG." (match-record config <guix-configuration> (guix build-group build-accounts authorize-key? authorized-keys use-substitutes? substitute-urls max-silent-time timeout - log-compression extra-options log-file http-proxy tmpdir - chroot-directories) + log-compression discover? extra-options log-file + http-proxy tmpdir chroot-directories) (list (shepherd-service (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))) @@ -1592,6 +1616,9 @@ proxy of 'guix-daemon'...~%") ;; 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. @@ -1606,6 +1633,8 @@ proxy of 'guix-daemon'...~%") #$@(if use-substitutes? '() '("--no-substitutes")) + (string-append "--discover=" + (if discover? "yes" "no")) "--substitute-urls" #$(string-join substitute-urls) #$@extra-options @@ -1689,17 +1718,18 @@ proxy of 'guix-daemon'...~%") "Return a file that contains the list of references of ITEM." (if (struct? item) ;lowerable object (computed-file name - (with-imported-modules (source-module-closure - '((guix build store-copy))) - #~(begin - (use-modules (guix build store-copy)) - - (call-with-output-file #$output - (lambda (port) - (write (map store-info-item - (call-with-input-file "graph" - read-reference-graph)) - port))))) + (with-extensions (list guile-gcrypt) ;for store-copy + (with-imported-modules (source-module-closure + '((guix build store-copy))) + #~(begin + (use-modules (guix build store-copy)) + + (call-with-output-file #$output + (lambda (port) + (write (map store-info-item + (call-with-input-file "graph" + read-reference-graph)) + port)))))) #:options `(#:local-build? #f #:references-graphs (("graph" ,item)))) (plain-file name "()"))) @@ -1744,6 +1774,8 @@ proxy of 'guix-daemon'...~%") (default 80)) (host guix-publish-configuration-host ;string (default "localhost")) + (advertise? guix-publish-advertise? ;boolean + (default #f)) (compression guix-publish-configuration-compression (thunked) (default (default-compression this-record @@ -1790,10 +1822,13 @@ raise a deprecation warning if the 'compression-level' field was used." lst)))) (match-record config <guix-publish-configuration> - (guix port host nar-path cache workers ttl cache-bypass-threshold) + (guix port host nar-path cache workers ttl cache-bypass-threshold + advertise?) (list (shepherd-service (provision '(guix-publish)) - (requirement '(guix-daemon)) + (requirement `(user-processes + guix-daemon + ,@(if advertise? '(avahi-daemon) '()))) (start #~(make-forkexec-constructor (list #$(file-append guix "/bin/guix") "publish" "-u" "guix-publish" @@ -1801,6 +1836,9 @@ raise a deprecation warning if the 'compression-level' field was used." #$@(config->compression-options config) (string-append "--nar-path=" #$nar-path) (string-append "--listen=" #$host) + #$@(if advertise? + #~("--advertise") + #~()) #$@(if workers #~((string-append "--workers=" #$(number->string |