From: Brice Waegeneire <brice@waegenei.re>
To: 49610@debbugs.gnu.org
Subject: [bug#49610] [PATCH 2/2] services: guix: Add channels field.
Date: Sat, 17 Jul 2021 23:04:24 +0200 [thread overview]
Message-ID: <20210717210424.1921-2-brice@waegenei.re> (raw)
In-Reply-To: <20210717205819.380-1-brice@waegenei.re>
* doc/guix.texi (Channels): Specify that '/etc/guix/channels.scm'
contains channels configuration.
(Base Services): Document 'guix-configuration-channels' field.
* gnu/services/base.scm (setup-channels): New procedure.
(guix-configuration): Add channels field.
(guix-activation): Use 'setup-channels' procedure.
---
doc/guix.texi | 14 +++++++++++++-
gnu/services/base.scm | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index cca46218f2..c930530228 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5001,7 +5001,7 @@ $ wget -O - \
Guix and its package collection are updated by running @command{guix pull}
(@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
deploys Guix itself from the official GNU@tie{}Guix repository. This can be
-customized by defining @dfn{channels} in the
+customized by defining @dfn{channels} in @file{/etc/guix/channels.scm} and
@file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
of a Git repository to be deployed, and @command{guix pull} can be instructed
to pull from one or more channels. In other words, channels can be used
@@ -15549,6 +15549,18 @@ This example assumes that the file @file{./guix.example.org-key.pub}
contains the public key that @code{guix.example.org} uses to sign
substitutes.
+@item @code{channels} (default: @code{'()})
+List of system channels to use, it populates
+@file{/etc/guix/channels.scm}.
+
+@quotation Note
+When booting or reconfiguring to a system where @code{channels}
+is not null, 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{0})
@itemx @code{timeout} (default: @code{0})
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 e206bea5f0..db63eb540b 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -58,6 +58,7 @@
#:use-module (gnu packages terminals)
#:use-module ((gnu build file-systems)
#:select (mount-flags->bit-mask))
+ #:use-module (guix channels)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (guix modules)
@@ -66,6 +67,7 @@
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
+ #:use-module (ice-9 pretty-print)
#:re-export (user-processes-service-type ;backwards compatibility
%default-substitute-urls)
#:export (fstab-service-type
@@ -1502,6 +1504,35 @@ archive' public keys, with GUIX."
;; Installed the declared ACL.
(symlink #+default-acl "/etc/guix/acl"))))
+;; FIXME Does this gexp should be build before boot, such as
+;; substitute-key-authorization does?
+(define (setup-channels channels)
+ "Return a gexp with code to setup CHANNELS, a list of channels"
+ (define channels-file
+ (plain-file "channels.scm"
+ (with-output-to-string
+ (lambda _
+ (pretty-print (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")
@@ -1524,6 +1555,8 @@ archive' public keys, with GUIX."
(default #t))
(substitute-urls guix-configuration-substitute-urls ;list of strings
(default %default-substitute-urls))
+ (channels guix-configuration-channels ;list of channels
+ (default '()))
(chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
(default '()))
(max-silent-time guix-configuration-max-silent-time ;integer
@@ -1701,7 +1734,7 @@ proxy of 'guix-daemon'...~%")
(define (guix-activation config)
"Return the activation gexp for CONFIG."
(match-record config <guix-configuration>
- (guix authorize-key? authorized-keys)
+ (guix 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,
@@ -1714,6 +1747,10 @@ proxy of 'guix-daemon'...~%")
#$(if authorize-key?
(substitute-key-authorization authorized-keys guix)
+ #~#f)
+
+ #$(if (not (null? channels))
+ (setup-channels channels)
#~#f))))
(define* (references-file item #:optional (name "references"))
--
2.32.0
next prev parent reply other threads:[~2021-07-17 21:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-17 20:58 [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Brice Waegeneire
2021-07-17 21:04 ` [bug#49610] [PATCH 1/2] services: guix: Use "match-record" in activation Brice Waegeneire
2021-07-21 21:47 ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Ludovic Courtès
2021-08-04 4:42 ` Brice Waegeneire
2021-07-17 21:04 ` Brice Waegeneire [this message]
2021-07-21 21:53 ` Ludovic Courtès
2021-09-01 21:16 ` Ludovic Courtès
2021-12-21 21:00 ` [bug#49610] [PATCH v2] sevices: guix: Add channels field Brice Waegeneire
2022-01-03 11:32 ` Ludovic Courtès
2023-05-25 20:12 ` [bug#49610] [PATCH v3] services: " Antero Mejr via Guix-patches via
2023-05-26 10:40 ` Simon Tournier
2023-05-26 16:29 ` Antero Mejr via Guix-patches via
2023-05-26 16:26 ` [bug#49610] [PATCH v4 1/2] " Antero Mejr via Guix-patches via
2023-05-26 16:26 ` [bug#49610] [PATCH v4 2/2] doc: guix.texi: Clarify wording in Channels section Antero Mejr via Guix-patches via
2024-03-22 10:45 ` Ludovic Courtès
2024-03-22 10:44 ` [bug#49610] [PATCH v4 1/2] services: guix: Add channels field Ludovic Courtès
2024-03-24 10:24 ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Franz Geffke
2024-04-04 8:03 ` Simon Tournier
2024-04-09 8:44 ` Franz Geffke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210717210424.1921-2-brice@waegenei.re \
--to=brice@waegenei.re \
--cc=49610@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.