diff options
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r-- | gnu/services/base.scm | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 2340cf1696..5104b3d104 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013-2023 Ludovic Courtès <[email protected]> +;;; Copyright © 2013-2024 Ludovic Courtès <[email protected]> ;;; Copyright © 2015, 2016 Alex Kost <[email protected]> ;;; Copyright © 2015, 2016, 2020 Mark H Weaver <[email protected]> ;;; Copyright © 2015 Sou Bunnbu <[email protected]> @@ -83,6 +83,7 @@ #:use-module ((gnu build file-systems) #:select (mount-flags->bit-mask swap-space->flags-bit-mask)) + #:autoload (guix channels) (%default-channels channel->code) #:use-module (guix gexp) #:use-module ((guix packages) #:select (package-version)) #:use-module (guix records) @@ -216,6 +217,7 @@ guix-configuration-use-substitutes? guix-configuration-substitute-urls guix-configuration-generate-substitute-key? + guix-configuration-channels guix-configuration-extra-options guix-configuration-log-file guix-configuration-environment @@ -1745,6 +1747,31 @@ archive' public keys, with GUIX." ;; Installed the declared ACL. (symlink #+default-acl acl-file)))) +(define (install-channels-file channels) + "Return a gexp with code to install CHANNELS, a list of channels, in +/etc/guix/channels.scm." + (define channels-file + (scheme-file "channels.scm" + `(list ,@(map channel->code channels)))) + + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + ;; If channels.scm already exists, move it out of the way. Create a + ;; backup if it's a regular file: it's likely that the user + ;; manually defined it. + (if (file-exists? "/etc/guix/channels.scm") + (if (and (symbolic-link? "/etc/guix/channels.scm") + (store-file-name? (readlink "/etc/guix/channels.scm"))) + (delete-file "/etc/guix/channels.scm") + (rename-file "/etc/guix/channels.scm" + "/etc/guix/channels.scm.bak")) + (mkdir-p "/etc/guix")) + + ;; Installed the declared channels. + (symlink #+channels-file "/etc/guix/channels.scm")))) + (define %default-authorized-guix-keys ;; List of authorized substitute keys. (list (file-append guix "/share/guix/berlin.guix.gnu.org.pub") @@ -1800,6 +1827,8 @@ archive' public keys, with GUIX." (default %default-substitute-urls)) (generate-substitute-key? guix-configuration-generate-substitute-key? (default #t)) ;Boolean + (channels guix-configuration-channels ;file-like + (default %default-channels)) (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings (default '())) (max-silent-time guix-configuration-max-silent-time ;integer @@ -1993,7 +2022,7 @@ proxy of 'guix-daemon'...~%") (define (guix-activation config) "Return the activation gexp for CONFIG." (match-record config <guix-configuration> - (guix generate-substitute-key? authorize-key? authorized-keys) + (guix generate-substitute-key? authorize-key? authorized-keys channels) #~(begin ;; Assume that the store has BUILD-GROUP as its group. We could ;; otherwise call 'chown' here, but the problem is that on a COW overlayfs, @@ -2010,6 +2039,9 @@ proxy of 'guix-daemon'...~%") (substitute-key-authorization authorized-keys guix) #~#f) + ;; ... and /etc/guix/channels.scm... + #$(and channels (install-channels-file channels)) + ;; ... and /etc/guix/machines.scm. #$(if (guix-build-machines config) (guix-machines-files-installation @@ -2179,15 +2211,10 @@ raise a deprecation warning if the 'compression-level' field was used." ;; Use lazy socket activation unless ADVERTISE? is true: in that ;; case the process should start right away to advertise itself. - (start #~(if (and (defined? 'make-systemd-constructor) ;> 0.9.0? - #$(not advertise?)) - (make-systemd-constructor - #$command #$endpoints #$@options) - (make-forkexec-constructor #$command #$@options))) - (stop #~(if (and (defined? 'make-systemd-destructor) - #$(not advertise?)) - (make-systemd-destructor) - (make-kill-destructor)))))))) + (start #~(make-systemd-constructor + #$command #$endpoints #$@options + #:lazy-start? #$(not advertise?))) + (stop #~(make-systemd-destructor))))))) (define %guix-publish-accounts (list (user-group (name "guix-publish") (system? #t)) |