unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
@ 2021-07-17 20:58 Brice Waegeneire
  2021-07-17 21:04 ` [bug#49610] [PATCH 1/2] services: guix: Use "match-record" in activation Brice Waegeneire
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Brice Waegeneire @ 2021-07-17 20:58 UTC (permalink / raw)
  To: 49610

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





^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 1/2] services: guix: Use "match-record" in activation.
  2021-07-17 20:58 [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Brice Waegeneire
@ 2021-07-17 21:04 ` Brice Waegeneire
  2021-07-21 21:47   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Ludovic Courtès
  2021-07-17 21:04 ` [bug#49610] [PATCH 2/2] services: guix: Add channels field Brice Waegeneire
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Brice Waegeneire @ 2021-07-17 21:04 UTC (permalink / raw)
  To: 49610

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@asu.edu>
 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
-;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
+;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
 ;;; Copyright © 2021 Hui Lu <luhuins@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





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 2/2] services: guix: Add channels field.
  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-17 21:04 ` Brice Waegeneire
  2021-07-21 21:53   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Ludovic Courtès
  2023-05-25 20:12 ` [bug#49610] [PATCH v3] services: " Antero Mejr via Guix-patches via
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Brice Waegeneire @ 2021-07-17 21:04 UTC (permalink / raw)
  To: 49610

* 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





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  2021-07-17 21:04 ` [bug#49610] [PATCH 1/2] services: guix: Use "match-record" in activation Brice Waegeneire
@ 2021-07-21 21:47   ` Ludovic Courtès
  2021-08-04  4:42     ` Brice Waegeneire
  0 siblings, 1 reply; 19+ messages in thread
From: Ludovic Courtès @ 2021-07-21 21:47 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 49610

Hello,

Brice Waegeneire <brice@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’.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  2021-07-17 21:04 ` [bug#49610] [PATCH 2/2] services: guix: Add channels field Brice Waegeneire
@ 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
  0 siblings, 2 replies; 19+ messages in thread
From: Ludovic Courtès @ 2021-07-21 21:53 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 49610

Brice Waegeneire <brice@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’.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  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
  0 siblings, 0 replies; 19+ messages in thread
From: Brice Waegeneire @ 2021-08-04  4:42 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 49610

Hello Ludo‘,

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

> Brice Waegeneire <brice@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




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  2021-07-21 21:53   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration 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
  1 sibling, 0 replies; 19+ messages in thread
From: Ludovic Courtès @ 2021-09-01 21:16 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 49610

Hello Brice,

Any update on this one?  :-)

Thanks in advance,
Ludo’.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v2] sevices: guix: Add channels field.
  2021-07-21 21:53   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Ludovic Courtès
  2021-09-01 21:16     ` Ludovic Courtès
@ 2021-12-21 21:00     ` Brice Waegeneire
  2022-01-03 11:32       ` Ludovic Courtès
  1 sibling, 1 reply; 19+ messages in thread
From: Brice Waegeneire @ 2021-12-21 21:00 UTC (permalink / raw)
  To: ludo; +Cc: 49610

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





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v2] sevices: guix: Add channels field.
  2021-12-21 21:00     ` [bug#49610] [PATCH v2] sevices: guix: Add channels field Brice Waegeneire
@ 2022-01-03 11:32       ` Ludovic Courtès
  0 siblings, 0 replies; 19+ messages in thread
From: Ludovic Courtès @ 2022-01-03 11:32 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 49610

Hi Brice,

Brice Waegeneire <brice@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@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’.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v3] services: guix: Add channels field.
  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-17 21:04 ` [bug#49610] [PATCH 2/2] services: guix: Add channels field Brice Waegeneire
@ 2023-05-25 20:12 ` Antero Mejr via Guix-patches via
  2023-05-26 10:40   ` Simon Tournier
  2023-05-26 16:26 ` [bug#49610] [PATCH v4 1/2] " Antero Mejr via Guix-patches via
  2024-03-24 10:24 ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Franz Geffke
  4 siblings, 1 reply; 19+ messages in thread
From: Antero Mejr via Guix-patches via @ 2023-05-25 20:12 UTC (permalink / raw)
  To: 49610; +Cc: ludo

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





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v3] services: guix: Add channels field.
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Tournier @ 2023-05-26 10:40 UTC (permalink / raw)
  To: Antero Mejr, 49610; +Cc: ludo

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




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v4 1/2] services: guix: Add channels field.
  2021-07-17 20:58 [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Brice Waegeneire
                   ` (2 preceding siblings ...)
  2023-05-25 20:12 ` [bug#49610] [PATCH v3] services: " Antero Mejr via Guix-patches via
@ 2023-05-26 16:26 ` 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: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
  4 siblings, 2 replies; 19+ messages in thread
From: Antero Mejr via Guix-patches via @ 2023-05-26 16:26 UTC (permalink / raw)
  To: 49610; +Cc: ludo, zimon.toutoune

* 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





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v4 2/2] doc: guix.texi: Clarify wording in Channels section.
  2023-05-26 16:26 ` [bug#49610] [PATCH v4 1/2] " Antero Mejr via Guix-patches via
@ 2023-05-26 16:26   ` 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
  1 sibling, 1 reply; 19+ messages in thread
From: Antero Mejr via Guix-patches via @ 2023-05-26 16:26 UTC (permalink / raw)
  To: 49610; +Cc: ludo, zimon.toutoune

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





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v3] services: guix: Add channels field.
  2023-05-26 10:40   ` Simon Tournier
@ 2023-05-26 16:29     ` Antero Mejr via Guix-patches via
  0 siblings, 0 replies; 19+ messages in thread
From: Antero Mejr via Guix-patches via @ 2023-05-26 16:29 UTC (permalink / raw)
  To: Simon Tournier; +Cc: 49610, ludo

Simon Tournier <zimon.toutoune@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.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v4 1/2] services: guix: Add channels field.
  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:44   ` Ludovic Courtès
  1 sibling, 0 replies; 19+ messages in thread
From: Ludovic Courtès @ 2024-03-22 10:44 UTC (permalink / raw)
  To: Antero Mejr; +Cc: 49610, zimon.toutoune

[-- Attachment #1: Type: text/plain, Size: 941 bytes --]

Hi Antero,

Antero Mejr <antero@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’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3961 bytes --]

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)

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH v4 2/2] doc: guix.texi: Clarify wording in Channels section.
  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
  0 siblings, 0 replies; 19+ messages in thread
From: Ludovic Courtès @ 2024-03-22 10:45 UTC (permalink / raw)
  To: Antero Mejr; +Cc: 49610-done, zimon.toutoune

Antero Mejr <antero@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’.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  2021-07-17 20:58 [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Brice Waegeneire
                   ` (3 preceding siblings ...)
  2023-05-26 16:26 ` [bug#49610] [PATCH v4 1/2] " Antero Mejr via Guix-patches via
@ 2024-03-24 10:24 ` Franz Geffke
  2024-04-04  8:03   ` Simon Tournier
  4 siblings, 1 reply; 19+ messages in thread
From: Franz Geffke @ 2024-03-24 10:24 UTC (permalink / raw)
  To: 49610

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?




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Tournier @ 2024-04-04  8:03 UTC (permalink / raw)
  To: Franz Geffke, 49610

Hi,

On dim., 24 mars 2024 at 10:24, Franz Geffke <franz@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@gnu.org>
Thu, 25 May 2023 20:12:16 +0000
id:20230525201216.16870-1-antero@mailbox.org
https://issues.guix.gnu.org/49610
https://issues.guix.gnu.org/msgid/20230525201216.16870-1-antero@mailbox.org
https://yhetil.org/guix/20230525201216.16870-1-antero@mailbox.org




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [bug#49610] [PATCH 0/2] Add channels field to guix-configuration
  2024-04-04  8:03   ` Simon Tournier
@ 2024-04-09  8:44     ` Franz Geffke
  0 siblings, 0 replies; 19+ messages in thread
From: Franz Geffke @ 2024-04-09  8:44 UTC (permalink / raw)
  To: Simon Tournier, 49610

[-- Attachment #1: Type: text/plain, Size: 280 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 465 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-04-09  8:46 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [bug#49610] [PATCH 2/2] services: guix: Add channels field Brice Waegeneire
2021-07-21 21:53   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration 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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).