GNU bug report logs - #49610
[PATCH 0/2] Add channels field to guix-configuration

Previous Next

Package: guix-patches;

Reported by: Brice Waegeneire <brice <at> waegenei.re>

Date: Sat, 17 Jul 2021 20:59:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49610 in the body.
You can then email your comments to 49610 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Sat, 17 Jul 2021 20:59:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Brice Waegeneire <brice <at> waegenei.re>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 17 Jul 2021 20:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Brice Waegeneire <brice <at> waegenei.re>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/2] Add channels field to guix-configuration
Date: Sat, 17 Jul 2021 22:58:19 +0200
This patchset brings the same feature as the authorized-keys but for channels;
allowing to sepcify the default channels an operating-system uses.  Allowing
an operating-system declaration to be self-contained in regards to channels

Brice Waegeneire (2):
  services: guix: Use "match-record" in activation.
  sevices: guix: Add channels field.

 doc/guix.texi         | 14 +++++++++-
 gnu/services/base.scm | 65 +++++++++++++++++++++++++++++++++----------
 2 files changed, 64 insertions(+), 15 deletions(-)

-- 
2.32.0





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Sat, 17 Jul 2021 21:05:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Brice Waegeneire <brice <at> waegenei.re>
To: guix-patches <at> gnu.org
Subject: [PATCH 1/2] services: guix: Use "match-record" in activation.
Date: Sat, 17 Jul 2021 23:04:23 +0200
It's more explicit to specify used fields instead of depending on their
position.

* gnu/services/base.scm (guix-activation): Replace "match" with
  "match-record".
---
 gnu/services/base.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index ab3e441a7b..e206bea5f0 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -12,7 +12,7 @@
 ;;; Copyright © 2019 John Soo <jsoo1 <at> asu.edu>
 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2020 Florian Pelz <pelzflorian <at> pelzflorian.de>
-;;; Copyright © 2020 Brice Waegeneire <brice <at> waegenei.re>
+;;; Copyright © 2020, 2021 Brice Waegeneire <brice <at> waegenei.re>
 ;;; Copyright © 2021 qblade <qblade <at> protonmail.com>
 ;;; Copyright © 2021 Hui Lu <luhuins <at> 163.com>
 ;;;
@@ -1700,21 +1700,21 @@ proxy of 'guix-daemon'...~%")
 
 (define (guix-activation config)
   "Return the activation gexp for CONFIG."
-  (match config
-    (($ <guix-configuration> guix build-group build-accounts authorize-key? keys)
-     ;; 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,
-     ;; chown leads to an entire copy of the tree, which is a bad idea.
+  (match-record config <guix-configuration>
+    (guix authorize-key? authorized-keys)
+    #~(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,
+        ;; chown leads to an entire copy of the tree, which is a bad idea.
 
-     ;; Generate a key pair and optionally authorize substitute server keys.
-     #~(begin
-         (unless (file-exists? "/etc/guix/signing-key.pub")
-           (system* #$(file-append guix "/bin/guix") "archive"
-                    "--generate-key"))
+        ;; Generate a key pair and optionally authorize substitute server keys.
+        (unless (file-exists? "/etc/guix/signing-key.pub")
+          (system* #$(file-append guix "/bin/guix") "archive"
+                   "--generate-key"))
 
-         #$(if authorize-key?
-               (substitute-key-authorization keys guix)
-               #~#f)))))
+        #$(if authorize-key?
+              (substitute-key-authorization authorized-keys guix)
+              #~#f))))
 
 (define* (references-file item #:optional (name "references"))
   "Return a file that contains the list of references of ITEM."
-- 
2.32.0





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Sat, 17 Jul 2021 21:05:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Brice Waegeneire <brice <at> waegenei.re>
To: guix-patches <at> gnu.org
Subject: [PATCH 2/2] services: guix: Add channels field.
Date: Sat, 17 Jul 2021 23:04:24 +0200
* 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 <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Wed, 21 Jul 2021 21:48:01 GMT) Full text and rfc822 format available.

Message #14 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Brice Waegeneire <brice <at> waegenei.re>
Cc: 49610 <at> debbugs.gnu.org
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
Date: Wed, 21 Jul 2021 23:47:04 +0200
Hello,

Brice Waegeneire <brice <at> waegenei.re> skribis:

> It's more explicit to specify used fields instead of depending on their
> position.
>
> * gnu/services/base.scm (guix-activation): Replace "match" with
>   "match-record".

LGTM!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Wed, 21 Jul 2021 21:54:01 GMT) Full text and rfc822 format available.

Message #17 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Brice Waegeneire <brice <at> waegenei.re>
Cc: 49610 <at> debbugs.gnu.org
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
Date: Wed, 21 Jul 2021 23:53:36 +0200
Brice Waegeneire <brice <at> waegenei.re> skribis:

> * 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.

[...]

> +@item @code{channels} (default: @code{'()})
> +List of system channels to use, it populates
> +@file{/etc/guix/channels.scm}.

What about:

  List of channels to be used by @command{guix pull}, by default.
  Channels listed here are written to @file{/etc/guix/channels.scm}.

?

> +;; FIXME Does this gexp should be build before boot, such as
> +;; substitute-key-authorization does?

There’s a grammatical issue :-), but also I’m not sure: what are you
worried about?

> +(define (setup-channels channels)
> +  "Return a gexp with code to setup CHANNELS, a list of channels"

Missing period.  For the name, how about ‘install-channels-file’
instead?

> +  (channels         guix-configuration-channels ;list of channels
> +                    (default '()))

I wonder if it should default to ‘%default-channels’, for consistency
and least-surprise.  In practice, it means we’d always end up creating
/etc/guix/channels.scm, but that’s probably OK.  (The downside is if we,
Guix devs, choose to change ‘%default-channels’ at some point: users
would be stuck with the value that got written to /etc.  That’s a very
hypothetical situation though.)

WDYT?

> +        #$(if (not (null? channels))
> +              (setup-channels channels)
>                #~#f))))

In that case, we could remove the (null? channels) special case.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Wed, 04 Aug 2021 04:43:01 GMT) Full text and rfc822 format available.

Message #20 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Brice Waegeneire <brice <at> waegenei.re>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49610 <at> debbugs.gnu.org
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
Date: Wed, 04 Aug 2021 06:42:34 +0200
Hello Ludo‘,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Brice Waegeneire <brice <at> waegenei.re> skribis:
>
>> It's more explicit to specify used fields instead of depending on their
>> position.
>>
>> * gnu/services/base.scm (guix-activation): Replace "match" with
>>   "match-record".
>
> LGTM!

Thanks, pushed as 92605326ae909471d17b0db51504e810989989f8.

Cheers,
- Brice




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Wed, 01 Sep 2021 21:17:02 GMT) Full text and rfc822 format available.

Message #23 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Brice Waegeneire <brice <at> waegenei.re>
Cc: 49610 <at> debbugs.gnu.org
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
Date: Wed, 01 Sep 2021 23:16:43 +0200
Hello Brice,

Any update on this one?  :-)

Thanks in advance,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Tue, 21 Dec 2021 21:02:01 GMT) Full text and rfc822 format available.

Message #26 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Brice Waegeneire <brice <at> waegenei.re>
To: ludo <at> gnu.org
Cc: 49610 <at> debbugs.gnu.org
Subject: [PATCH v2] sevices: guix: Add channels field.
Date: Tue, 21 Dec 2021 22:00:42 +0100
* doc/guix.texi (Channels): Specify that '/etc/guix/channels.scm'
  contains channels configuration.
  (Base Services): Document 'guix-configuration-channels' field.
* gnu/services/base.scm (install-channels-file): New procedure.
  (guix-configuration): Add channels field.
  (guix-activation): Use 'install-channels-file' procedure.
---
 doc/guix.texi         | 15 ++++++++++++++-
 gnu/services/base.scm | 42 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 54 insertions(+), 3 deletions(-)

I've changed the type of the new field from a list to a s-expression, I'm not
sure if it should be a G-exp instead.  The documentation of the
'channels' field as been updated as suggested.

Ludovic Courtès <ludo <at> gnu.org> writes:

>> +;; FIXME Does this gexp should be build before boot, such as
>> +;; substitute-key-authorization does?
>
> There’s a grammatical issue :-), but also I’m not sure: what are you
> worried about?

This is related to your commit 8b3ad455be7e8ace35a2eaebf7fffbb611280852, where
you added pre-computation of the ACL to make « [...] the first boot slightly
faster ».  Should this be done in this case too?

>> +  (channels         guix-configuration-channels ;list of channels
>> +                    (default '()))
>
> I wonder if it should default to ‘%default-channels’, for consistency
> and least-surprise.  In practice, it means we’d always end up creating
> /etc/guix/channels.scm, but that’s probably OK.  (The downside is if we,
> Guix devs, choose to change ‘%default-channels’ at some point: users
> would be stuck with the value that got written to /etc.  That’s a very
> hypothetical situation though.)

Users would not have been stuck with a stale ‘%default-channels’, even with
the first version of this patch.  The issue with using a non null default
value, is the absence of backward compatibility.  A user with an already defined
/etc/guix/chanels.scm, would see its custom channels being replaced by the
default one after having reconfigure a system with this patch for the first
time.  So I guess I should make further adjustment to the patch

¹ <https://git.savannah.gnu.org/cgit/guix.git/commit/?id=8b3ad455be7e8ace35a2eaebf7fffbb611280852>


diff --git a/doc/guix.texi b/doc/guix.texi
index a826171f34..5284a69156 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 <at> 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
@@ -15557,6 +15557,19 @@ 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{'(cons* %default-channels)})
+S-expression producing a list of channels to be used by @command{guix
+pull}, by default.  The S-exp is written to
+@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..c9823e6d55 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,39 @@ archive' public keys, with GUIX."
         ;; Installed the declared ACL.
         (symlink #+default-acl "/etc/guix/acl"))))
 
+;; FIXME Does this gexp should be built before boot, such as
+;; substitute-key-authorization does?
+(define (install-channels-file channels)
+  "Return a gexp with code to install a file with CHANNELS, a S-exp returning
+a list of channels."
+  (define channels-file
+    (plain-file "channels.scm"
+                (with-output-to-string
+                  (lambda _
+                    (pretty-print (map (lambda (channel)
+                                         (if (channel? channel)
+                                             (channel->code channel)
+                                             channel))
+                                       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 +1559,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 ;sexp
+                    (default '(cons* %default-channels)))
   (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
                       (default '()))
   (max-silent-time  guix-configuration-max-silent-time ;integer
@@ -1701,7 +1738,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,7 +1751,8 @@ proxy of 'guix-daemon'...~%")
 
         #$(if authorize-key?
               (substitute-key-authorization authorized-keys guix)
-              #~#f))))
+              #~#f)
+        #$(install-channels-file channels))))
 
 (define* (references-file item #:optional (name "references"))
   "Return a file that contains the list of references of ITEM."
-- 
2.32.0





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Mon, 03 Jan 2022 11:33:02 GMT) Full text and rfc822 format available.

Message #29 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Brice Waegeneire <brice <at> waegenei.re>
Cc: 49610 <at> debbugs.gnu.org
Subject: Re: [PATCH v2] sevices: guix: Add channels field.
Date: Mon, 03 Jan 2022 12:32:31 +0100
Hi Brice,

Brice Waegeneire <brice <at> waegenei.re> skribis:

> * doc/guix.texi (Channels): Specify that '/etc/guix/channels.scm'
>   contains channels configuration.
>   (Base Services): Document 'guix-configuration-channels' field.
> * gnu/services/base.scm (install-channels-file): New procedure.
>   (guix-configuration): Add channels field.
>   (guix-activation): Use 'install-channels-file' procedure.
> ---
>  doc/guix.texi         | 15 ++++++++++++++-
>  gnu/services/base.scm | 42 ++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 54 insertions(+), 3 deletions(-)
>
> I've changed the type of the new field from a list to a s-expression, I'm not
> sure if it should be a G-exp instead.  The documentation of the
> 'channels' field as been updated as suggested.

It’s OK to keep it this way.

> Ludovic Courtès <ludo <at> gnu.org> writes:
>
>>> +;; FIXME Does this gexp should be build before boot, such as
>>> +;; substitute-key-authorization does?
>>
>> There’s a grammatical issue :-), but also I’m not sure: what are you
>> worried about?
>
> This is related to your commit 8b3ad455be7e8ace35a2eaebf7fffbb611280852, where
> you added pre-computation of the ACL to make « [...] the first boot slightly
> faster ».  Should this be done in this case too?

Ah no, commit 8b3ad455be7e8ace35a2eaebf7fffbb611280852 is about
pre-generating /etc/guix/acl.  In the case of /etc/guix/channels.scm,
there’s nothing to pre-generate though since we’re just dumping the sexp
as-is to /etc/guix/channels.scm, so I think this comment can be safely
removed.

[...]

> +@item @code{channels} (default: @code{'(cons* %default-channels)})

I’d make the default #~%default-channels, no need for ‘cons*’.

> +@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

“When (…) where @code{channels} is not null” does not match the actual
code, does it?

Otherwise LGTM, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Thu, 25 May 2023 20:13:01 GMT) Full text and rfc822 format available.

Message #32 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: 49610 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: [PATCH v3] services: guix: Add channels field.
Date: Thu, 25 May 2023 20:12:16 +0000
* doc/guix.texi (Channels): Specify that '/etc/guix/channels.scm'
contains channels configuration.
(Base Services): Document 'guix-configuration-channels' field.
* gnu/services/base.scm (install-channels-file): New procedure.
(%default-channels-file): New variable.
(guix-configuration): Add channels field.
(guix-activation): Use 'install-channels-file' procedure.
---
Updated v3 patch.
Changed the channels field to accept a file-like object instead of an
S-expression. I think this is more flexible because it lets users
specify a local-file rather than just an sexp.

I think this will be a unexpected/breaking change for Guix System users. If they
have /etc/guix/channels.scm customized manually, on their next 'guix system
reconfigure', it will move that file and use the channels field, unless they
modify guix-configuration.  Maybe this change should have a NEWS entry?

 doc/guix.texi         | 17 +++++++++++++++--
 gnu/services/base.scm | 44 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 31dc33fb97..d0367ab8c5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5397,8 +5397,8 @@ $ 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 <at> tie{}Guix repository.  This can be
-customized by defining @dfn{channels} in the
-@file{~/.config/guix/channels.scm} file.  A channel specifies a URL and branch
+customized by defining @dfn{channels} in the @file{/etc/guix/channels.scm} and
+@file{~/.config/guix/channels.scm} files.  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
 to @emph{customize} and to @emph{extend} Guix, as we will see below.
@@ -18858,6 +18858,19 @@ 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.
 
+@item @code{channels} (default: @code{%default-channels-file})
+File-like object containing a list of channels to be used by
+@command{guix pull}, by default.  The file-like object is symlinked to
+@file{/etc/guix/channels.scm}.
+
+@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{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 c5b06b57e8..e61bf6eac7 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -80,6 +80,7 @@ (define-module (gnu services base)
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
+  #:use-module (guix channels)
   #:use-module (guix gexp)
   #:use-module (guix records)
   #:use-module (guix modules)
@@ -93,6 +94,7 @@ (define-module (gnu services base)
   #:use-module (srfi srfi-35)
   #: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
@@ -207,6 +209,7 @@ (define-module (gnu services base)
             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
@@ -1739,6 +1742,39 @@ (define acl-file #$%acl-file)
         ;; Installed the declared ACL.
         (symlink #+default-acl acl-file))))
 
+(define %default-channels-file
+  ;; File-like object containing the default list of channels.
+  (plain-file "channels.scm"
+              (with-output-to-string
+                (lambda _
+                  (pretty-print (map (lambda (channel)
+                                       (if (channel? channel)
+                                           (channel->code channel)
+                                           channel))
+                                     %default-channels))))))
+
+;; FIXME: Should this gexp be built before boot, like
+;; substitute-key-authorization does?
+(define (install-channels-file channels-file)
+  "Return a gexp with code to install CHANNELS-FILE, a file-like object."
+  (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")
@@ -1763,6 +1799,8 @@ (define-record-type* <guix-configuration>
                     (default %default-substitute-urls))
   (generate-substitute-key? guix-configuration-generate-substitute-key?
                             (default #t))         ;Boolean
+  (channels         guix-configuration-channels ;file-like
+                    (default %default-channels-file))
   (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
                       (default '()))
   (max-silent-time  guix-configuration-max-silent-time ;integer
@@ -1949,7 +1987,7 @@ (define (guix-accounts config)
 (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,
@@ -1963,7 +2001,9 @@ (define (guix-activation config)
 
         #$(if authorize-key?
               (substitute-key-authorization authorized-keys guix)
-              #~#f))))
+              #~#f)
+
+        #$(install-channels-file channels))))
 
 (define-record-type* <guix-extension>
   guix-extension make-guix-extension
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Fri, 26 May 2023 11:26:02 GMT) Full text and rfc822 format available.

Message #35 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Antero Mejr <antero <at> mailbox.org>, 49610 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: [bug#49610] [PATCH v3] services: guix: Add channels field.
Date: Fri, 26 May 2023 12:40:40 +0200
Hi,

Sorry if I am missing something.  A comment about the consistency of the
manual. :-)  The section “Invoking guix pull” mentions:

        Specifically, @command{guix pull} downloads code from the @dfn{channels}
        (@pxref{Channels}) specified by one of the followings, in this order:

        @enumerate
        @item
        the @option{--channels} option;
        @item
        the user's @file{~/.config/guix/channels.scm} file;
        @item
        the system-wide @file{/etc/guix/channels.scm} file;
        @item
        the built-in default channels specified in the @code{%default-channels}
        variable.
        @end enumerate

On jeu., 25 mai 2023 at 20:12, Antero Mejr via Guix-patches via <guix-patches <at> gnu.org> wrote:

> -customized by defining @dfn{channels} in the
> -@file{~/.config/guix/channels.scm} file.  A channel specifies a URL and branch
> +customized by defining @dfn{channels} in the @file{/etc/guix/channels.scm} and
> +@file{~/.config/guix/channels.scm} files.  A channel specifies a URL and branch

I find this wording confusing.  I would suggest:

--8<---------------cut here---------------start------------->8---
A channel specifies a URL and branch customized by defining
@dfn{channels} in the @file{~/.config/guix/channels.scm} file, and/or
the @file{/etc/guix/channels.scm} file and/or the built-in default
specified in the @code{%default-channels} variable.  Guix honors the
channels file in that previous order (@xref{Invoking guix pull}).
--8<---------------cut here---------------end--------------->8---

or something like that.  Keeping in mind that this part is not Guix
System specific.

WDYT?

Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Fri, 26 May 2023 16:27:02 GMT) Full text and rfc822 format available.

Message #38 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: 49610 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, zimon.toutoune <at> gmail.com
Subject: [PATCH v4 1/2] services: guix: Add channels field.
Date: Fri, 26 May 2023 16:26:05 +0000
* doc/guix.texi (Base Services): Document
'guix-configuration-channels' field.
* gnu/services/base.scm (install-channels-file): New procedure.
(%default-channels-file): New variable.
(guix-configuration): Add channels field.
(guix-activation): Use 'install-channels-file' procedure.
---
 doc/guix.texi         | 13 +++++++++++++
 gnu/services/base.scm | 40 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 31dc33fb97..9ebdf70d81 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18858,6 +18858,19 @@ 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.
 
+@item @code{channels} (default: @code{%default-channels-file})
+File-like object containing a list of channels to be used by
+@command{guix pull}, by default.  The file-like object is symlinked to
+@file{/etc/guix/channels.scm}.
+
+@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{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 c5b06b57e8..ee0c4880f9 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -80,6 +80,7 @@ (define-module (gnu services base)
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
+  #:use-module (guix channels)
   #:use-module (guix gexp)
   #:use-module (guix records)
   #:use-module (guix modules)
@@ -93,6 +94,7 @@ (define-module (gnu services base)
   #:use-module (srfi srfi-35)
   #: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
@@ -207,6 +209,7 @@ (define-module (gnu services base)
             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
@@ -1739,6 +1742,35 @@ (define acl-file #$%acl-file)
         ;; Installed the declared ACL.
         (symlink #+default-acl acl-file))))
 
+(define %default-channels-file
+  ;; File-like object containing the default list of channels.
+  (plain-file "channels.scm"
+              (with-output-to-string
+                (lambda _
+                  (pretty-print (map channel->code %default-channels))))))
+
+;; FIXME: Should this gexp be built before boot, like
+;; substitute-key-authorization does?
+(define (install-channels-file channels-file)
+  "Return a gexp with code to install CHANNELS-FILE, a file-like object."
+  (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")
@@ -1763,6 +1795,8 @@ (define-record-type* <guix-configuration>
                     (default %default-substitute-urls))
   (generate-substitute-key? guix-configuration-generate-substitute-key?
                             (default #t))         ;Boolean
+  (channels         guix-configuration-channels ;file-like
+                    (default %default-channels-file))
   (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
                       (default '()))
   (max-silent-time  guix-configuration-max-silent-time ;integer
@@ -1949,7 +1983,7 @@ (define (guix-accounts config)
 (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,
@@ -1963,7 +1997,9 @@ (define (guix-activation config)
 
         #$(if authorize-key?
               (substitute-key-authorization authorized-keys guix)
-              #~#f))))
+              #~#f)
+
+        #$(install-channels-file channels))))
 
 (define-record-type* <guix-extension>
   guix-extension make-guix-extension
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Fri, 26 May 2023 16:27:02 GMT) Full text and rfc822 format available.

Message #41 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: 49610 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, zimon.toutoune <at> gmail.com
Subject: [PATCH v4 2/2] doc: guix.texi: Clarify wording in Channels section.
Date: Fri, 26 May 2023 16:26:06 +0000
* doc/guix.texi (Channels): Specify that '/etc/guix/channels.scm'
contains channels configuration.
---
 doc/guix.texi | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 9ebdf70d81..643a36358d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5396,14 +5396,15 @@ $ wget -O - \
 @cindex configuration of @command{guix pull}
 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 <at> tie{}Guix repository.  This can be
-customized by defining @dfn{channels} in the
-@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
-to @emph{customize} and to @emph{extend} Guix, as we will see below.
-Guix is able to take into account security concerns and deal with authenticated
-updates.
+deploys Guix itself from the official GNU <at> tie{}Guix repository.  A
+channel specifies a URL and branch customized by defining @dfn{channels}
+in the @file{~/.config/guix/channels.scm} file, and/or the
+@file{/etc/guix/channels.scm} file and/or the built-in default specified
+in the @code{%default-channels} variable.  Guix honors the channels file
+in that previous order (@xref{Invoking guix pull}).  In other words,
+channels can be used to @emph{customize} and to @emph{extend} Guix, as
+we will see below.  Guix is able to take into account security concerns
+and deal with authenticated updates.
 
 @menu
 * Specifying Additional Channels::  Extending the package collection.
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Fri, 26 May 2023 16:31:02 GMT) Full text and rfc822 format available.

Message #44 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: Simon Tournier <zimon.toutoune <at> gmail.com>
Cc: 49610 <at> debbugs.gnu.org, ludo <at> gnu.org
Subject: Re: [bug#49610] [PATCH v3] services: guix: Add channels field.
Date: Fri, 26 May 2023 16:29:49 +0000
Simon Tournier <zimon.toutoune <at> gmail.com> writes:

> Sorry if I am missing something.  A comment about the consistency of the
> manual. :-)  The section “Invoking guix pull” mentions:
>
> (snip)
>
>> -customized by defining @dfn{channels} in the
>> -@file{~/.config/guix/channels.scm} file.  A channel specifies a URL and branch
>> +customized by defining @dfn{channels} in the @file{/etc/guix/channels.scm} and
>> +@file{~/.config/guix/channels.scm} files.  A channel specifies a URL and branch
>
> I find this wording confusing.  I would suggest:
>
> A channel specifies a URL and branch customized by defining
> @dfn{channels} in the @file{~/.config/guix/channels.scm} file, and/or
> the @file{/etc/guix/channels.scm} file and/or the built-in default
> specified in the @code{%default-channels} variable.  Guix honors the
> channels file in that previous order (@xref{Invoking guix pull}).
>
> or something like that.  Keeping in mind that this part is not Guix
> System specific.

Updated to use that wording in v4. I put the documentation update for
the Channels section into a separate patch, as that change isn't related
to the guix-configuration changes.




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Fri, 22 Mar 2024 10:54:02 GMT) Full text and rfc822 format available.

Message #47 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Antero Mejr <antero <at> mailbox.org>
Cc: 49610 <at> debbugs.gnu.org, zimon.toutoune <at> gmail.com
Subject: Re: [bug#49610] [PATCH v4 1/2] services: guix: Add channels field.
Date: Fri, 22 Mar 2024 11:44:14 +0100
[Message part 1 (text/plain, inline)]
Hi Antero,

Antero Mejr <antero <at> mailbox.org> skribis:

> * doc/guix.texi (Base Services): Document
> 'guix-configuration-channels' field.
> * gnu/services/base.scm (install-channels-file): New procedure.
> (%default-channels-file): New variable.
> (guix-configuration): Add channels field.
> (guix-activation): Use 'install-channels-file' procedure.

Rebased and finally applied!

However, I took the liberty to make the changes below.  Essentially,
‘channels’ is now a list of channel (as the name suggests) rather than a
file-like.  It’s a tradeoff: on one hand it’s less expressive (that
prevents users from sticking arbitrary Scheme code in there), but OTOH
it’s easier to use.

If that is deemed too rigid, we can revisit that and either allow for
file-like objects or for gexps, or add a separate ‘channels-file’ field.

Pushed as 883e69cdfd226c8f40b6e3b76ce0740b59857de6.

Thanks!

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/doc/guix.texi b/doc/guix.texi
index 5c974f2ea4..e419b8d1a4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4727,7 +4727,9 @@ Invoking guix pull
 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,10 +19808,11 @@ Base Services
 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})
-File-like object containing a list of channels to be used by
-@command{guix pull}, by default.  The file-like object is symlinked to
-@file{/etc/guix/channels.scm}.
+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}
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index dcd66b8064..cd61df718e 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -83,7 +83,7 @@ (define-module (gnu services base)
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
-  #:use-module (guix channels)
+  #:autoload   (guix channels) (%default-channels channel->code)
   #:use-module (guix gexp)
   #:use-module (guix records)
   #:use-module (guix modules)
@@ -98,7 +98,6 @@ (define-module (gnu services base)
   #:use-module (srfi srfi-35)
   #: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
@@ -1743,17 +1742,13 @@ (define (substitute-key-authorization keys guix)
         ;; Installed the declared ACL.
         (symlink #+default-acl acl-file))))
 
-(define %default-channels-file
-  ;; File-like object containing the default list of channels.
-  (plain-file "channels.scm"
-              (with-output-to-string
-                (lambda _
-                  (pretty-print (map channel->code %default-channels))))))
+(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))))
 
-;; FIXME: Should this gexp be built before boot, like
-;; substitute-key-authorization does?
-(define (install-channels-file channels-file)
-  "Return a gexp with code to install CHANNELS-FILE, a file-like object."
   (with-imported-modules '((guix build utils))
     #~(begin
         (use-modules (guix build utils))
@@ -1828,7 +1823,7 @@ (define-record-type* <guix-configuration>
   (generate-substitute-key? guix-configuration-generate-substitute-key?
                             (default #t))         ;Boolean
   (channels         guix-configuration-channels ;file-like
-                    (default %default-channels-file))
+                    (default %default-channels))
   (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
                       (default '()))
   (max-silent-time  guix-configuration-max-silent-time ;integer
@@ -2040,7 +2035,7 @@ (define (guix-activation config)
               #~#f)
 
         ;; ... and /etc/guix/channels.scm...
-        #$(install-channels-file channels)
+        #$(and channels (install-channels-file channels))
 
         ;; ... and /etc/guix/machines.scm.
         #$(if (guix-build-machines config)

bug closed, send any further explanations to 49610 <at> debbugs.gnu.org and Brice Waegeneire <brice <at> waegenei.re> Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 22 Mar 2024 10:54:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Fri, 22 Mar 2024 10:54:03 GMT) Full text and rfc822 format available.

Message #52 received at 49610-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Antero Mejr <antero <at> mailbox.org>
Cc: 49610-done <at> debbugs.gnu.org, zimon.toutoune <at> gmail.com
Subject: Re: [bug#49610] [PATCH v4 2/2] doc: guix.texi: Clarify wording in
 Channels section.
Date: Fri, 22 Mar 2024 11:45:17 +0100
Antero Mejr <antero <at> mailbox.org> skribis:

> * doc/guix.texi (Channels): Specify that '/etc/guix/channels.scm'
> contains channels configuration.

I went with simpler wording to avoid repeating the file name ordering
specified in “Invoking guix pull”.

Pushed as b5018807ee4b09962507b67f7506cbdc70d6c810.

Thanks for your work… and for your patience!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Sun, 24 Mar 2024 10:56:02 GMT) Full text and rfc822 format available.

Message #55 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Franz Geffke <franz <at> pantherx.org>
To: 49610 <at> debbugs.gnu.org
Subject: Re: [PATCH 0/2] Add channels field to guix-configuration
Date: Sun, 24 Mar 2024 10:24:43 +0000
As of yesterday the channels file on my computer has been replaced by a symlink 
to the default channels; I guess hundreds of PC's that rely on automatic 
updates, are now stuck on this commit.

Is this expected?




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Thu, 04 Apr 2024 17:23:01 GMT) Full text and rfc822 format available.

Message #58 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Franz Geffke <franz <at> pantherx.org>, 49610 <at> debbugs.gnu.org
Subject: Re: [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
Date: Thu, 04 Apr 2024 10:03:49 +0200
Hi,

On dim., 24 mars 2024 at 10:24, Franz Geffke <franz <at> pantherx.org> wrote:
> As of yesterday the channels file on my computer has been replaced by a symlink 
> to the default channels; I guess hundreds of PC's that rely on automatic 
> updates, are now stuck on this commit.
>
> Is this expected?

I guess yes, as mentioned in [1]:

        I think this will be a unexpected/breaking change for Guix System users. If they
        have /etc/guix/channels.scm customized manually, on their next 'guix system
        reconfigure', it will move that file and use the channels field, unless they
        modify guix-configuration.  Maybe this change should have a NEWS entry?

But the ’reconfigure’ should be smooth.  Is it still an issue for you?

Cheers,
simon


1: [bug#49610] [PATCH v3] services: guix: Add channels field.
Antero Mejr via Guix-patches via <guix-patches <at> gnu.org>
Thu, 25 May 2023 20:12:16 +0000
id:20230525201216.16870-1-antero <at> mailbox.org
https://issues.guix.gnu.org/49610
https://issues.guix.gnu.org/msgid/20230525201216.16870-1-antero <at> mailbox.org
https://yhetil.org/guix/20230525201216.16870-1-antero <at> mailbox.org




Information forwarded to guix-patches <at> gnu.org:
bug#49610; Package guix-patches. (Tue, 09 Apr 2024 08:46:02 GMT) Full text and rfc822 format available.

Message #61 received at 49610 <at> debbugs.gnu.org (full text, mbox):

From: "Franz Geffke" <franz <at> pantherx.org>
To: "Simon Tournier" <zimon.toutoune <at> gmail.com>, 49610 <at> debbugs.gnu.org
Subject: Re: [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
Date: Tue, 09 Apr 2024 09:44:55 +0100
[Message part 1 (text/plain, inline)]
> But the ’reconfigure’ should be smooth.  Is it still an issue for you?

You're totally right; I suspect the issue was caused by a wrapper we have around the system configuration, to automate some stuff. It's working perfectly now, and I very much appreciate these changes.
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 07 May 2024 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.