diff options
author | Ludovic Courtès <ludo@gnu.org> | 2025-03-22 17:36:42 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-04-06 11:24:01 +0200 |
commit | b16e3f451f0117450e71eb74871d8329f776a997 (patch) | |
tree | a2139ead6fdf23addcf5349c2defef648ef6ca28 | |
parent | 21221710f247b755f00f851ba7acedbef9bd7def (diff) | |
download | guix-b16e3f451f0117450e71eb74871d8329f776a997.tar.gz guix-b16e3f451f0117450e71eb74871d8329f776a997.zip |
services: guix: Factorize ‘guix-daemon’ arguments.
* gnu/services/base.scm (guix-shepherd-service): In ‘start’ method,
move ‘fork+exec-command/container’ arguments to the new variables
‘daemon-command’ and ‘environment-variables’.
Change-Id: Ic04a1006849697e4e185ad94185bbdec8a91a05a
-rw-r--r-- | gnu/services/base.scm | 115 |
1 files changed, 59 insertions, 56 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 0d2bb31190..6793822666 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -2061,6 +2061,63 @@ proxy of 'guix-daemon'...~%") (define discover? (or (getenv "discover") #$discover?)) + (define daemon-command + (cons* #$(file-append guix "/bin/guix-daemon") + "--build-users-group" #$build-group + "--max-silent-time" + #$(number->string max-silent-time) + "--timeout" #$(number->string timeout) + "--log-compression" + #$(symbol->string log-compression) + #$@(if use-substitutes? + '() + '("--no-substitutes")) + (string-append "--discover=" + (if discover? "yes" "no")) + "--substitute-urls" #$(string-join substitute-urls) + #$@extra-options + + #$@(if chroot? + '() + '("--disable-chroot")) + ;; Add CHROOT-DIRECTORIES and all their dependencies + ;; (if these are store items) to the chroot. + (append-map + (lambda (file) + (append-map (lambda (directory) + (list "--chroot-directory" + directory)) + (call-with-input-file file + read))) + '#$(map references-file + chroot-directories)))) + + (define environment-variables + (append (list #$@(if tmpdir + (list (string-append "TMPDIR=" tmpdir)) + '()) + + ;; Make sure we run in a UTF-8 locale so that + ;; 'guix offload' correctly restores nars + ;; that contain UTF-8 file names such as + ;; 'nss-certs'. See + ;; <https://bugs.gnu.org/32942>. + (string-append "GUIX_LOCPATH=" + #$locales "/lib/locale") + "LC_ALL=en_US.utf8" + ;; Make 'tar' and 'gzip' available so + ;; that 'guix perform-download' can use + ;; them when downloading from Software + ;; Heritage via '(guix swh)'. + (string-append "PATH=" + #$(file-append tar "/bin") ":" + #$(file-append gzip "/bin"))) + (if proxy + (list (string-append "http_proxy=" proxy) + (string-append "https_proxy=" proxy)) + '()) + '#$environment)) + (mkdir-p "/var/guix") ;; Ensure that a fresh directory is used, in case the old ;; one was more permissive and processes have a file @@ -2084,35 +2141,7 @@ proxy of 'guix-daemon'...~%") ;; to solve an installation issue. See the comment below for ;; more details. (fork+exec-command/container - (cons* #$(file-append guix "/bin/guix-daemon") - "--build-users-group" #$build-group - "--max-silent-time" - #$(number->string max-silent-time) - "--timeout" #$(number->string timeout) - "--log-compression" - #$(symbol->string log-compression) - #$@(if use-substitutes? - '() - '("--no-substitutes")) - (string-append "--discover=" - (if discover? "yes" "no")) - "--substitute-urls" #$(string-join substitute-urls) - #$@extra-options - - #$@(if chroot? - '() - '("--disable-chroot")) - ;; Add CHROOT-DIRECTORIES and all their dependencies - ;; (if these are store items) to the chroot. - (append-map - (lambda (file) - (append-map (lambda (directory) - (list "--chroot-directory" - directory)) - (call-with-input-file file - read))) - '#$(map references-file - chroot-directories))) + daemon-command ;; When running the installer, we need guix-daemon to ;; operate from within the same MNT namespace as the @@ -2123,33 +2152,7 @@ proxy of 'guix-daemon'...~%") #:pid (match args ((pid) (string->number pid)) (else (getpid))) - - #:environment-variables - (append (list #$@(if tmpdir - (list (string-append "TMPDIR=" tmpdir)) - '()) - - ;; Make sure we run in a UTF-8 locale so that - ;; 'guix offload' correctly restores nars - ;; that contain UTF-8 file names such as - ;; 'nss-certs'. See - ;; <https://bugs.gnu.org/32942>. - (string-append "GUIX_LOCPATH=" - #$locales "/lib/locale") - "LC_ALL=en_US.utf8" - ;; Make 'tar' and 'gzip' available so - ;; that 'guix perform-download' can use - ;; them when downloading from Software - ;; Heritage via '(guix swh)'. - (string-append "PATH=" - #$(file-append tar "/bin") ":" - #$(file-append gzip "/bin"))) - (if proxy - (list (string-append "http_proxy=" proxy) - (string-append "https_proxy=" proxy)) - '()) - '#$environment) - + #:environment-variables environment-variables #:log-file #$log-file)))) (stop #~(make-kill-destructor)))))) |