[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/09: services: guix: Add ‘channels’ field.
From: |
guix-commits |
Subject: |
01/09: services: guix: Add ‘channels’ field. |
Date: |
Fri, 22 Mar 2024 06:43:00 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 883e69cdfd226c8f40b6e3b76ce0740b59857de6
Author: Antero Mejr <antero@mailbox.org>
AuthorDate: Fri May 26 16:26:05 2023 +0000
services: guix: Add ‘channels’ field.
* doc/guix.texi (Base Services): Document
'guix-configuration-channels' field.
(Invoking guix pull): Add cross-reference.
* gnu/services/base.scm (install-channels-file): New procedure.
(guix-configuration): Add channels field.
(guix-activation): Use 'install-channels-file' procedure.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Change-Id: I4d89235bf0bc6dde69984138ccb894b48ace9d76
---
doc/guix.texi | 18 +++++++++++++++++-
gnu/services/base.scm | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index b353d91bd5..e419b8d1a4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4727,7 +4727,9 @@ the user's @file{~/.config/guix/channels.scm} file,
unless @option{-q}
is passed;
@item
the system-wide @file{/etc/guix/channels.scm} file, unless @option{-q}
-is passed;
+is passed (on Guix System, this file can be declared in the operating
+system configuration, @pxref{guix-configuration-channels,
+@code{channels} field of @code{guix-configuration}});
@item
the built-in default channels specified in the @code{%default-channels}
variable.
@@ -19806,6 +19808,20 @@ few seconds when enough entropy is available and is
only done once; you
might want to turn it off for instance in a virtual machine that does
not need it and where the extra boot time is a problem.
+@anchor{guix-configuration-channels}
+@item @code{channels} (default: @code{%default-channels})
+List of channels to be specified in @file{/etc/guix/channels.scm}, which
+is what @command{guix pull} uses by default (@pxref{Invoking guix
+pull}).
+
+@quotation Note
+When reconfiguring a system, the existing @file{/etc/guix/channels.scm}
+file is backed up as @file{/etc/guix/channels.scm.bak} if it was
+determined to be a manually modified file. This is to facilitate
+migration from earlier versions, which allowed for in-place
+modifications to @file{/etc/guix/channels.scm}.
+@end quotation
+
@item @code{max-silent-time} (default: @code{3600})
@itemx @code{timeout} (default: @code{(* 3600 24)})
The number of seconds of silence and the number of seconds of activity,
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 4c3821d4e3..cd61df718e 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -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 records)
#:use-module (guix modules)
@@ -211,6 +212,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
@@ -1740,6 +1742,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")
@@ -1795,6 +1822,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
@@ -1988,7 +2017,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,
@@ -2005,6 +2034,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
- branch master updated (3d2966e0b7 -> 40f53e8fb5), guix-commits, 2024/03/22
- 02/09: doc: Mention channel files beyond ~/.config/guix., guix-commits, 2024/03/22
- 05/09: gnu: arcan-sdl: Add missing inputs., guix-commits, 2024/03/22
- 09/09: gnu: mu: Update to 1.12.2., guix-commits, 2024/03/22
- 03/09: system, home: Validate ‘services’ field value., guix-commits, 2024/03/22
- 01/09: services: guix: Add ‘channels’ field.,
guix-commits <=
- 04/09: gnu: mupdf: Update to 1.23.11., guix-commits, 2024/03/22
- 06/09: gnu: Add gvisor-tap-vsock., guix-commits, 2024/03/22
- 07/09: gnu: distrobox: Update to 1.7.0., guix-commits, 2024/03/22
- 08/09: gnu: distrobox: Fix dependency usage., guix-commits, 2024/03/22