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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Brice Waegeneire <brice@HIDDEN>; Keywords: patch; Done: Ludovic Courtès <ludo@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 49610-done <at> debbugs.gnu.org:


Received: (at 49610-done) by debbugs.gnu.org; 22 Mar 2024 10:53:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 22 06:53:58 2024
Received: from localhost ([127.0.0.1]:42557 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rncX7-0001Vo-Vf
	for submit <at> debbugs.gnu.org; Fri, 22 Mar 2024 06:53:58 -0400
Received: from eggs.gnu.org ([209.51.188.92]:39862)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rncX1-0001Ul-73
 for 49610-done <at> debbugs.gnu.org; Fri, 22 Mar 2024 06:53:52 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rncOl-0003ds-30; Fri, 22 Mar 2024 06:45:19 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=JVPH26PAwZd2ofihlbN+E1eh+7MdBnZ/FuIDNbkQ0Hw=; b=RqWTMZ7sD1KR5QIiG8my
 i+0wmmbD4oIIdLPErOt8H3FozFH+CoiLOOOGhfS5RUuHRTIWUg+HZrXc+D9CdumFdCWuM3x1f6+lZ
 3Yf55iblqnhBxonMJplGYPA5wpC30wl1vpPsBgyOSJ+8JtdRGcG7vF/Mo8SR27cEMUVGfZCyn29eP
 O9vs0jV1lhD+tBtgekLYYCohJUpEXzdVY9BxaPaRJXKN5kAlV+eRbNnbm0nCOYSdZhytwWdwBfzV3
 ZEeLN49QF7Sf9ghZN6/IFTYXkPATgQugsdvuc1QrcjP1tjsBFS2eEOSOHjAXaF7vCekkYxMr4Cjt/
 iJV50zwuE5iteA==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Antero Mejr <antero@HIDDEN>
Subject: Re: [bug#49610] [PATCH v4 2/2] doc: guix.texi: Clarify wording in
 Channels section.
In-Reply-To: <20230526162606.6747-2-antero@HIDDEN> (Antero Mejr's message
 of "Fri, 26 May 2023 16:26:06 +0000")
References: <20230526162606.6747-1-antero@HIDDEN>
 <20230526162606.6747-2-antero@HIDDEN>
Date: Fri, 22 Mar 2024 11:45:17 +0100
Message-ID: <87o7b6sfya.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 49610-done
Cc: 49610-done <at> debbugs.gnu.org, zimon.toutoune@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Antero Mejr <antero@HIDDEN> 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 =E2=80=9CInvoking guix pull=E2=80=9D.

Pushed as b5018807ee4b09962507b67f7506cbdc70d6c810.

Thanks for your work=E2=80=A6 and for your patience!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.
bug closed, send any further explanations to 49610 <at> debbugs.gnu.org and Brice Waegeneire <brice@HIDDEN> Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 22 Mar 2024 10:53:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 22 06:53:59 2024
Received: from localhost ([127.0.0.1]:42559 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rncX8-0001W0-HN
	for submit <at> debbugs.gnu.org; Fri, 22 Mar 2024 06:53:59 -0400
Received: from eggs.gnu.org ([209.51.188.92]:39862)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rncX2-0001Ul-Jo
 for 49610 <at> debbugs.gnu.org; Fri, 22 Mar 2024 06:53:53 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rncNn-0003ZI-IK; Fri, 22 Mar 2024 06:44:19 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=lCFIaJmKM40OCvPEp178HOWZwgWKKJ2OUQxrL8os+1E=; b=FU6OeqJ0oH1zIT4Wik0j
 HtzVv2XIFKKpqLkBPzmRwZ+IdM+ldCUckqAifNnlIQi+GaVLOyBAtzhE5mh70uQqEbzYv8Cj1emrN
 nv2iobX67gm8/fx3jwV1/h5QCdxq9EKsRThA638olDcPb6+yMnst83Zga0wlbx0h84cy2ke2BFmh4
 pOUPEi6agAWMiWURHkZrzksY1HhaNf93BlIFC7EpTMZR1hMaDqQWyI05w5RrVG/NeE1fRLRfcm/Xx
 GL9SpeEfnu2W0EgCFB8ds+olvTudavW9jGIHUkCe+8vM9GD9m9qrG+zMW4uVoiDqp+bb3JtrjdpEw
 Il3+SZfGcSPARw==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Antero Mejr <antero@HIDDEN>
Subject: Re: [bug#49610] [PATCH v4 1/2] services: guix: Add channels field.
In-Reply-To: <20230526162606.6747-1-antero@HIDDEN> (Antero Mejr's message
 of "Fri, 26 May 2023 16:26:05 +0000")
References: <20210717205819.380-1-brice@HIDDEN>
 <20230526162606.6747-1-antero@HIDDEN>
Date: Fri, 22 Mar 2024 11:44:14 +0100
Message-ID: <87sf0isg01.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org, zimon.toutoune@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Antero,

Antero Mejr <antero@HIDDEN> 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,
=E2=80=98channels=E2=80=99 is now a list of channel (as the name suggests) =
rather than a
file-like.  It=E2=80=99s a tradeoff: on one hand it=E2=80=99s less expressi=
ve (that
prevents users from sticking arbitrary Scheme code in there), but OTOH
it=E2=80=99s 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 =E2=80=98channels-file=E2=
=80=99 field.

Pushed as 883e69cdfd226c8f40b6e3b76ce0740b59857de6.

Thanks!

Ludo=E2=80=99.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: 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)

--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 26 May 2023 16:30:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 26 12:30:06 2023
Received: from localhost ([127.0.0.1]:50687 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q2aKL-0003FY-U0
	for submit <at> debbugs.gnu.org; Fri, 26 May 2023 12:30:06 -0400
Received: from mout-p-103.mailbox.org ([80.241.56.161]:40216)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <antero@HIDDEN>) id 1q2aKJ-0003EZ-LT
 for 49610 <at> debbugs.gnu.org; Fri, 26 May 2023 12:30:04 -0400
Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest
 SHA256) (No client certificate requested)
 by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4QSVkm15Zzz9sdQ;
 Fri, 26 May 2023 18:29:52 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
 s=mail20150812; t=1685118592;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=gwZc8B7a9nJkmQzjiMavOUNKBX0V6ikejFsoFHDFOxQ=;
 b=iQjeY0KY/630S+35GCtkpwXlwGJdz7RDWNmLVa7fGpzd1HJf5OLDalDprUiC4dsOI8o/la
 fXqSfefTk/GLEvE/CZb1TjcKaXHgzRaKjkxqR2oof2uYxsKKKScJwtxW914B4y3uevOS3P
 a5PRnzg1rLw0R5IPS9Qxe4716dMBVE/QKx7CjqX4uqOGJwJWX6J5IWbXO4dfTKdNEri8yK
 /tEaDxJz028iT+v4igy3XUgmnt2AmoPBKf+sbSVDQjB8SIJMwGnDOxE/VToT8DnhS/M2XV
 t1jx7Hg8wyd8/v48TMCnW9vGbmRHJma0uMnIQB6tpEyH+kSCE6fIXzlTJkPpCQ==
From: Antero Mejr <antero@HIDDEN>
To: Simon Tournier <zimon.toutoune@HIDDEN>
Subject: Re: [bug#49610] [PATCH v3] services: guix: Add channels field.
In-Reply-To: <87lehbtlxz.fsf@HIDDEN> (Simon Tournier's message of "Fri, 26
 May 2023 12:40:40 +0200")
References: <20210717205819.380-1-brice@HIDDEN>
 <20230525201216.16870-1-antero@HIDDEN> <87lehbtlxz.fsf@HIDDEN>
Date: Fri, 26 May 2023 16:29:49 +0000
Message-ID: <87a5xrvywy.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-MBO-RS-ID: 9983ae3937b45c68e9b
X-MBO-RS-META: irpprhbz1wajgyupg7b77ekdxydbf91o
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org, ludo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Simon Tournier <zimon.toutoune@HIDDEN> writes:

> Sorry if I am missing something.  A comment about the consistency of the
> manual. :-)  The section =E2=80=9CInvoking guix pull=E2=80=9D 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.s=
cm} and
>> +@file{~/.config/guix/channels.scm} files.  A channel specifies a URL an=
d 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@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 26 May 2023 16:26:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 26 12:26:29 2023
Received: from localhost ([127.0.0.1]:50676 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q2aGr-00039O-7P
	for submit <at> debbugs.gnu.org; Fri, 26 May 2023 12:26:29 -0400
Received: from mout-p-103.mailbox.org ([80.241.56.161]:34986)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <antero@HIDDEN>) id 1q2aGn-00038v-Ru
 for 49610 <at> debbugs.gnu.org; Fri, 26 May 2023 12:26:26 -0400
Received: from smtp202.mailbox.org (smtp202.mailbox.org
 [IPv6:2001:67c:2050:b231:465::202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest
 SHA256) (No client certificate requested)
 by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4QSVfZ22SFz9sdC;
 Fri, 26 May 2023 18:26:14 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
 s=mail20150812; t=1685118374;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=LUrsRyESr6tffv4DXqW4KsWj3SpGZ7eYDT4jcccOZHs=;
 b=Bjxe3h3xP/tQPb2rLcUKgKE6EN5srM3yU3Kqw1ImdYr8GfXMdbsGKoR0cz8rRq1B4iImwl
 o92zB8x2yR0jg3MW30qb7ug0CGWHHv5BLnO28SN34tBt2e93HAJoyMtvoJAUQ1Ymx+xqcz
 5JEJNfCJT18raxI3k4cZRymhxydbOw8AP3ar7Zm2L5NqpnOCwPByo3NAB4upS2mIeNDRQM
 rgOQ+x/O+f3EtQ2I+JNikxzoHqMMcA5Xp2qCiYFuaU28nvbB+4zScOW0eNKVtiidH3nTAz
 LM2I2AQdGl/BVJCXjO4u39nDzIC3P9cm48NegVbeMrzu0fMQ/rWn6z91Vfju5g==
From: Antero Mejr <antero@HIDDEN>
To: 49610 <at> debbugs.gnu.org
Subject: [PATCH v4 2/2] doc: guix.texi: Clarify wording in Channels section.
Date: Fri, 26 May 2023 16:26:06 +0000
Message-Id: <20230526162606.6747-2-antero@HIDDEN>
In-Reply-To: <20230526162606.6747-1-antero@HIDDEN>
References: <20230526162606.6747-1-antero@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-MBO-RS-ID: 415eb2f7e095857f755
X-MBO-RS-META: 65srwmh73y3cj9dywsy858cgg5k3fus4
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49610
Cc: ludo@HIDDEN, zimon.toutoune@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* 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





Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 26 May 2023 16:26:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 26 12:26:27 2023
Received: from localhost ([127.0.0.1]:50674 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q2aGo-000399-B2
	for submit <at> debbugs.gnu.org; Fri, 26 May 2023 12:26:27 -0400
Received: from mout-p-202.mailbox.org ([80.241.56.172]:42264)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <antero@HIDDEN>) id 1q2aGm-00038r-SI
 for 49610 <at> debbugs.gnu.org; Fri, 26 May 2023 12:26:25 -0400
Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest
 SHA256) (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4QSVfX6Rclz9ssc;
 Fri, 26 May 2023 18:26:12 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
 s=mail20150812; t=1685118372;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding;
 bh=CpDr/hktiK8QND3jK5avAN6/G0ZGs5l4s3+hJ7rcWWo=;
 b=GrGt3yk2BwOF1z/Mc85CXhNeblB+KoEiOP2qGhYednpe21bBnb17C4BZQ0TZITQfQXbiIc
 BcK4Du7+lRcvqMfLnWOKiKNcDC7pb8/ppdZk/jeZsFobqJK/FoIHOS/8TxoRYmDCm5kFUD
 MmRz9kO0ffNHs2m5NLuQkHLzCEYTLO1+tb+gSmtwYONyBFhGmJ1dE17f2L1RMx2pRXd6k9
 fop7R49zEt8k4w6K4pHumOpqe/CJGKr04JyhD0gTLTJqdH+gn/C6uLq+MOSO453FQZeEJg
 36NFrxdVFkCI0EK6BHWSNo2dQvSUqzRrm+hXopyZDmciaU5rqwI4CeSjaYUShw==
From: Antero Mejr <antero@HIDDEN>
To: 49610 <at> debbugs.gnu.org
Subject: [PATCH v4 1/2] services: guix: Add channels field.
Date: Fri, 26 May 2023 16:26:05 +0000
Message-Id: <20230526162606.6747-1-antero@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-MBO-RS-META: uyijabr1utymf1zz9mcfmc7ny4xzo9e3
X-MBO-RS-ID: 5cde06eba5612d44fd5
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49610
Cc: ludo@HIDDEN, zimon.toutoune@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* 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@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 26 May 2023 11:25:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 26 07:25:36 2023
Received: from localhost ([127.0.0.1]:48993 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q2VZg-0008Fj-Cc
	for submit <at> debbugs.gnu.org; Fri, 26 May 2023 07:25:36 -0400
Received: from mail-wr1-f51.google.com ([209.85.221.51]:39392)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1q2VZT-0008Ep-FX
 for 49610 <at> debbugs.gnu.org; Fri, 26 May 2023 07:25:35 -0400
Received: by mail-wr1-f51.google.com with SMTP id
 ffacd0b85a97d-30ad48957f5so56348f8f.1
 for <49610 <at> debbugs.gnu.org>; Fri, 26 May 2023 04:25:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1685100318; x=1687692318;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=xeNL6dY/C8VxRqASHlCaDWxXRCJ6CZcgCYZ71F2B9Tc=;
 b=jaE8+1xrRamM69B6Coqh6XL3dN2ss1QE7RRY2y3HNM60EJcIx219qbnmpZj++BEQP6
 qS/9Q7YyAb3NxAfI6jGjNIjKdFZ0/TRtnRaX8bD3DygkzAX5kPdADcrNmmIN2qbGP16Z
 Jyj99k8TmMOfjIv9T/O+R4cNdZ+e422xPu37TIA+ZBnE6BTJTB7qBE/5+k19PfMUHGx/
 K1ZhkumLsvJ9tZV3nKJWIP35lDjRN9apchRp3W1+PIFsV4claUn/6U6qxEloxawATLoR
 uTWM93h01lb7tE7XI83hDZvL84t3HlWiSAKIvVsUSoqjT0kdwnvwa2SCJbs629MV/shl
 1rJA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1685100318; x=1687692318;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=xeNL6dY/C8VxRqASHlCaDWxXRCJ6CZcgCYZ71F2B9Tc=;
 b=M3pDl+JX8KcGpcIn27mDr2r81JU8qiVYatitvWbD4XyKODRY8DMEdRtymPMKbzXv1C
 xB6cBjy+yd8ZpahBLsXIQwNTBGaoLxnLZVyIxRdqwX19bznHKBoBIEzqRCRt7xqcoOVd
 /zDtdDthxIFFA8u8JPcqHY9+bD+lfddEuMhXeYD8vk6VmWCOI2rzxufwQ13PkPLEjjWb
 Gy5oOEU5FUgJWlC43SO1QxnzsDxT2md9X2K4nCYA7u7gdhXlZD8sBEHBDpsKtLWXZPP1
 q56kYiDxFRAEd3omLw4Y3Bq2MYG4vQ9zm/qQkhZmI0L/avzMQderrBTCvg5w3o24+JEN
 KVkQ==
X-Gm-Message-State: AC+VfDwJ0VQyxLojvq5xpXmKZ7xdHldYrv/9j0igVyFBIxCgITIr4x6x
 X3H6HspUF7Jedk0C51PvMtc=
X-Google-Smtp-Source: ACHHUZ77dmGtB0vHY4OTGYBtyK5o3e57aDZNAROcDfcIIv2itU2XRHYVyS1x3QhiVGuvzMbODMuu0A==
X-Received: by 2002:adf:ec44:0:b0:2fe:e605:a8cd with SMTP id
 w4-20020adfec44000000b002fee605a8cdmr917833wrn.6.1685100317843; 
 Fri, 26 May 2023 04:25:17 -0700 (PDT)
Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id
 h2-20020adff4c2000000b0030631f199f9sm4861861wrp.34.2023.05.26.04.25.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 26 May 2023 04:25:17 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: Antero Mejr <antero@HIDDEN>, 49610 <at> debbugs.gnu.org
Subject: Re: [bug#49610] [PATCH v3] services: guix: Add channels field.
In-Reply-To: <20230525201216.16870-1-antero@HIDDEN>
References: <20210717205819.380-1-brice@HIDDEN>
 <20230525201216.16870-1-antero@HIDDEN>
Date: Fri, 26 May 2023 12:40:40 +0200
Message-ID: <87lehbtlxz.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 49610
Cc: ludo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Sorry if I am missing something.  A comment about the consistency of the
manual. :-)  The section =E2=80=9CInvoking guix pull=E2=80=9D mentions:

        Specifically, @command{guix pull} downloads code from the @dfn{chan=
nels}
        (@pxref{Channels}) specified by one of the followings, in this orde=
r:

        @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-chann=
els}
        variable.
        @end enumerate

On jeu., 25 mai 2023 at 20:12, Antero Mejr via Guix-patches via <guix-patch=
es@HIDDEN> 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.sc=
m} 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@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 25 May 2023 20:12:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 25 16:12:43 2023
Received: from localhost ([127.0.0.1]:48228 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q2HKE-0005pi-MH
	for submit <at> debbugs.gnu.org; Thu, 25 May 2023 16:12:43 -0400
Received: from mout-p-201.mailbox.org ([80.241.56.171]:52790)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <antero@HIDDEN>) id 1q2HKB-0005pO-8J
 for 49610 <at> debbugs.gnu.org; Thu, 25 May 2023 16:12:41 -0400
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:b231:465::2])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest
 SHA256) (No client certificate requested)
 by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4QRzk32WzRz9snt;
 Thu, 25 May 2023 22:12:27 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
 s=mail20150812; t=1685045547;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding;
 bh=t0YE/tUUnysGJ/ix8taLAdJdbn0hnsvXWk4gUgxWK3c=;
 b=O/agdFLAQhk/F9WFZn71RxoDVOYRR4abPJJbb+2HOhHv+n5huUTMSuB+cKKi4K8sn8UqVR
 zKjqKfIhA68UEuIczfUZk7r9xJdxCt/BXEElT/uYxGq2F9PQ/mdDCgizmXFfG3Sv5VoHvD
 XwJCSeW9vvytzSDMRQ/4QOmQdFUFjLd+DBd5WQm+vq4tFrrZjusMdYBpq02OXGS53E5Nqr
 iQb6K2qadrVo1+Ze9OW4kCEkwIiK7INENBkaSYIzJ56n4BHkobVTolgwnH2UFe511LGcIc
 TQwPPn8Ga/beA4msmvMiS4tRRfB4EjQpLjzsve6BjWxypmS3JJNyCaRl7XRHWw==
From: Antero Mejr <antero@HIDDEN>
To: 49610 <at> debbugs.gnu.org
Subject: [PATCH v3] services: guix: Add channels field.
Date: Thu, 25 May 2023 20:12:16 +0000
Message-Id: <20230525201216.16870-1-antero@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-MBO-RS-ID: 021eddfe7f0470a8ad1
X-MBO-RS-META: ni3zdxi47x61ssohximn7jrszttgwiww
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49610
Cc: ludo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* 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





Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 3 Jan 2022 11:32:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 03 06:32:44 2022
Received: from localhost ([127.0.0.1]:34278 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n4LZz-0006JA-UT
	for submit <at> debbugs.gnu.org; Mon, 03 Jan 2022 06:32:44 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:55562)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1n4LZw-0006Is-MW
 for 49610 <at> debbugs.gnu.org; Mon, 03 Jan 2022 06:32:42 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id B2B4A2C3;
 Mon,  3 Jan 2022 12:32:33 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id KOiKNH4C6J-d; Mon,  3 Jan 2022 12:32:32 +0100 (CET)
Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 1AF6113B;
 Mon,  3 Jan 2022 12:32:32 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Brice Waegeneire <brice@HIDDEN>
Subject: Re: [PATCH v2] sevices: guix: Add channels field.
References: <87sg07e3kv.fsf_-_@HIDDEN>
 <20211221210042.6302-1-brice@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 14 =?utf-8?Q?Niv=C3=B4se?= an 230 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 03 Jan 2022 12:32:31 +0100
In-Reply-To: <20211221210042.6302-1-brice@HIDDEN> (Brice Waegeneire's
 message of "Tue, 21 Dec 2021 22:00:42 +0100")
Message-ID: <87v8z1kqb4.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: B2B4A2C3
X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[];
 RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWO(0.00)[2];
 FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[];
 TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain];
 FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+];
 RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[];
 MID_RHS_MATCH_FROM(0.00)[]
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi Brice,

Brice Waegeneire <brice@HIDDEN> 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=E2=80=99s OK to keep it this way.

> Ludovic Court=C3=A8s <ludo@HIDDEN> writes:
>
>>> +;; FIXME Does this gexp should be build before boot, such as
>>> +;; substitute-key-authorization does?
>>
>> There=E2=80=99s a grammatical issue :-), but also I=E2=80=99m not sure: =
what are you
>> worried about?
>
> This is related to your commit 8b3ad455be7e8ace35a2eaebf7fffbb611280852, =
where
> you added pre-computation of the ACL to make =C2=AB [...] the first boot =
slightly
> faster =C2=BB.  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=E2=80=99s nothing to pre-generate though since we=E2=80=99re just dum=
ping 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=E2=80=99d make the default #~%default-channels, no need for =E2=80=98cons=
*=E2=80=99.

> +@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 u=
p 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

=E2=80=9CWhen (=E2=80=A6) where @code{channels} is not null=E2=80=9D does n=
ot match the actual
code, does it?

Otherwise LGTM, thanks!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 21 Dec 2021 21:01:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 21 16:01:02 2021
Received: from localhost ([127.0.0.1]:55849 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mzmFm-00035T-Hd
	for submit <at> debbugs.gnu.org; Tue, 21 Dec 2021 16:01:02 -0500
Received: from relay4-d.mail.gandi.net ([217.70.183.196]:54043)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brice@HIDDEN>) id 1mzmFg-00035C-DX
 for 49610 <at> debbugs.gnu.org; Tue, 21 Dec 2021 16:00:56 -0500
Received: (Authenticated sender: brice@HIDDEN)
 by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 18677E0007;
 Tue, 21 Dec 2021 21:00:45 +0000 (UTC)
From: Brice Waegeneire <brice@HIDDEN>
To: ludo@HIDDEN
Subject: [PATCH v2] sevices: guix: Add channels field.
Date: Tue, 21 Dec 2021 22:00:42 +0100
Message-Id: <20211221210042.6302-1-brice@HIDDEN>
X-Mailer: git-send-email 2.34.0
In-Reply-To: <87sg07e3kv.fsf_-_@HIDDEN>
References: <87sg07e3kv.fsf_-_@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

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





Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 1 Sep 2021 21:16:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 01 17:16:55 2021
Received: from localhost ([127.0.0.1]:39106 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mLXbL-00039u-0V
	for submit <at> debbugs.gnu.org; Wed, 01 Sep 2021 17:16:55 -0400
Received: from eggs.gnu.org ([209.51.188.92]:47234)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mLXbH-00039h-6j
 for 49610 <at> debbugs.gnu.org; Wed, 01 Sep 2021 17:16:51 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38408)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mLXbB-0008JB-4W; Wed, 01 Sep 2021 17:16:45 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48824 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mLXbA-0002cq-SP; Wed, 01 Sep 2021 17:16:45 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Brice Waegeneire <brice@HIDDEN>
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
References: <20210717205819.380-1-brice@HIDDEN>
 <20210717210424.1921-2-brice@HIDDEN> <87sg07e3kv.fsf_-_@HIDDEN>
Date: Wed, 01 Sep 2021 23:16:43 +0200
In-Reply-To: <87sg07e3kv.fsf_-_@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s?=
 =?utf-8?Q?=22's?= message of "Wed, 21 Jul 2021 23:53:36 +0200")
Message-ID: <877dg06lok.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello Brice,

Any update on this one?  :-)

Thanks in advance,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 4 Aug 2021 04:42:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 04 00:42:48 2021
Received: from localhost ([127.0.0.1]:42105 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mB8jw-0000Sp-P9
	for submit <at> debbugs.gnu.org; Wed, 04 Aug 2021 00:42:48 -0400
Received: from relay12.mail.gandi.net ([217.70.178.232]:42325)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brice@HIDDEN>) id 1mB8ju-0000SZ-4p
 for 49610 <at> debbugs.gnu.org; Wed, 04 Aug 2021 00:42:47 -0400
Received: (Authenticated sender: brice@HIDDEN)
 by relay12.mail.gandi.net (Postfix) with ESMTPSA id 4F9D3200002;
 Wed,  4 Aug 2021 04:42:38 +0000 (UTC)
From: Brice Waegeneire <brice@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
References: <20210717205819.380-1-brice@HIDDEN>
 <20210717210424.1921-1-brice@HIDDEN> <87wnpje3vr.fsf_-_@HIDDEN>
Date: Wed, 04 Aug 2021 06:42:34 +0200
In-Reply-To: <87wnpje3vr.fsf_-_@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s?=
 =?utf-8?Q?=22's?= message of "Wed, 21 Jul 2021 23:47:04 +0200")
Message-ID: <87eeb9izwl.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hello Ludo=E2=80=98,

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> Brice Waegeneire <brice@HIDDEN> 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@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 21 Jul 2021 21:53:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 21 17:53:44 2021
Received: from localhost ([127.0.0.1]:38833 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m6K9w-0003kC-Cv
	for submit <at> debbugs.gnu.org; Wed, 21 Jul 2021 17:53:44 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38238)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1m6K9v-0003k1-7p
 for 49610 <at> debbugs.gnu.org; Wed, 21 Jul 2021 17:53:43 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:35572)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1m6K9p-0007fi-IP; Wed, 21 Jul 2021 17:53:37 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=45282 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1m6K9p-0000Qj-Ai; Wed, 21 Jul 2021 17:53:37 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Brice Waegeneire <brice@HIDDEN>
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
References: <20210717205819.380-1-brice@HIDDEN>
 <20210717210424.1921-2-brice@HIDDEN>
Date: Wed, 21 Jul 2021 23:53:36 +0200
In-Reply-To: <20210717210424.1921-2-brice@HIDDEN> (Brice Waegeneire's
 message of "Sat, 17 Jul 2021 23:04:24 +0200")
Message-ID: <87sg07e3kv.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Brice Waegeneire <brice@HIDDEN> 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=E2=80=99s a grammatical issue :-), but also I=E2=80=99m not sure: wha=
t 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 =E2=80=98install-channels-file=E2=
=80=99
instead?

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

I wonder if it should default to =E2=80=98%default-channels=E2=80=99, for c=
onsistency
and least-surprise.  In practice, it means we=E2=80=99d always end up creat=
ing
/etc/guix/channels.scm, but that=E2=80=99s probably OK.  (The downside is i=
f we,
Guix devs, choose to change =E2=80=98%default-channels=E2=80=99 at some poi=
nt: users
would be stuck with the value that got written to /etc.  That=E2=80=99s a v=
ery
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=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at 49610 <at> debbugs.gnu.org:


Received: (at 49610) by debbugs.gnu.org; 21 Jul 2021 21:47:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 21 17:47:14 2021
Received: from localhost ([127.0.0.1]:38824 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m6K3e-0003at-Hv
	for submit <at> debbugs.gnu.org; Wed, 21 Jul 2021 17:47:14 -0400
Received: from eggs.gnu.org ([209.51.188.92]:36904)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1m6K3c-0003af-3e
 for 49610 <at> debbugs.gnu.org; Wed, 21 Jul 2021 17:47:12 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:35482)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1m6K3W-00036d-6K; Wed, 21 Jul 2021 17:47:06 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=45280 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1m6K3V-0008MC-VL; Wed, 21 Jul 2021 17:47:06 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Brice Waegeneire <brice@HIDDEN>
Subject: Re: bug#49610: [PATCH 0/2] Add channels field to guix-configuration
References: <20210717205819.380-1-brice@HIDDEN>
 <20210717210424.1921-1-brice@HIDDEN>
Date: Wed, 21 Jul 2021 23:47:04 +0200
In-Reply-To: <20210717210424.1921-1-brice@HIDDEN> (Brice Waegeneire's
 message of "Sat, 17 Jul 2021 23:04:23 +0200")
Message-ID: <87wnpje3vr.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 49610
Cc: 49610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello,

Brice Waegeneire <brice@HIDDEN> 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=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jul 2021 21:04:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 17 17:04:47 2021
Received: from localhost ([127.0.0.1]:54688 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m4rUI-0007tD-Mc
	for submit <at> debbugs.gnu.org; Sat, 17 Jul 2021 17:04:47 -0400
Received: from lists.gnu.org ([209.51.188.17]:49528)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brice@HIDDEN>) id 1m4rUC-0007sv-UL
 for submit <at> debbugs.gnu.org; Sat, 17 Jul 2021 17:04:41 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47888)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brice@HIDDEN>) id 1m4rUC-0001a0-Oo
 for guix-patches@HIDDEN; Sat, 17 Jul 2021 17:04:36 -0400
Received: from relay9-d.mail.gandi.net ([217.70.183.199]:57009)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brice@HIDDEN>) id 1m4rU7-0002ep-CJ
 for guix-patches@HIDDEN; Sat, 17 Jul 2021 17:04:36 -0400
Received: (Authenticated sender: brice@HIDDEN)
 by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 68722FF803
 for <guix-patches@HIDDEN>; Sat, 17 Jul 2021 21:04:28 +0000 (UTC)
From: Brice Waegeneire <brice@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 2/2] services: guix: Add channels field.
Date: Sat, 17 Jul 2021 23:04:24 +0200
Message-Id: <20210717210424.1921-2-brice@HIDDEN>
X-Mailer: git-send-email 2.32.0
In-Reply-To: <20210717205819.380-1-brice@HIDDEN>
References: <20210717205819.380-1-brice@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=217.70.183.199; envelope-from=brice@HIDDEN;
 helo=relay9-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

* 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





Information forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jul 2021 21:04:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 17 17:04:41 2021
Received: from localhost ([127.0.0.1]:54685 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m4rUC-0007st-91
	for submit <at> debbugs.gnu.org; Sat, 17 Jul 2021 17:04:41 -0400
Received: from lists.gnu.org ([209.51.188.17]:49522)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brice@HIDDEN>) id 1m4rU9-0007sk-Ax
 for submit <at> debbugs.gnu.org; Sat, 17 Jul 2021 17:04:35 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47886)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brice@HIDDEN>) id 1m4rU9-0001We-5c
 for guix-patches@HIDDEN; Sat, 17 Jul 2021 17:04:33 -0400
Received: from relay7-d.mail.gandi.net ([217.70.183.200]:60935)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brice@HIDDEN>) id 1m4rU7-0002eD-99
 for guix-patches@HIDDEN; Sat, 17 Jul 2021 17:04:32 -0400
Received: (Authenticated sender: brice@HIDDEN)
 by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id A948D20002
 for <guix-patches@HIDDEN>; Sat, 17 Jul 2021 21:04:26 +0000 (UTC)
From: Brice Waegeneire <brice@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 1/2] services: guix: Use "match-record" in activation.
Date: Sat, 17 Jul 2021 23:04:23 +0200
Message-Id: <20210717210424.1921-1-brice@HIDDEN>
X-Mailer: git-send-email 2.32.0
In-Reply-To: <20210717205819.380-1-brice@HIDDEN>
References: <20210717205819.380-1-brice@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=217.70.183.200; envelope-from=brice@HIDDEN;
 helo=relay7-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

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@HIDDEN>
 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@HIDDEN>
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@HIDDEN>
-;;; Copyright © 2020 Brice Waegeneire <brice@HIDDEN>
+;;; Copyright © 2020, 2021 Brice Waegeneire <brice@HIDDEN>
 ;;; Copyright © 2021 qblade <qblade@HIDDEN>
 ;;; Copyright © 2021 Hui Lu <luhuins@HIDDEN>
 ;;;
@@ -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@HIDDEN:
bug#49610; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jul 2021 20:58:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 17 16:58:30 2021
Received: from localhost ([127.0.0.1]:54672 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m4rOH-0007iM-QG
	for submit <at> debbugs.gnu.org; Sat, 17 Jul 2021 16:58:29 -0400
Received: from lists.gnu.org ([209.51.188.17]:46996)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brice@HIDDEN>) id 1m4rOF-0007iE-Mq
 for submit <at> debbugs.gnu.org; Sat, 17 Jul 2021 16:58:28 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:46900)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brice@HIDDEN>) id 1m4rOF-0007wc-DY
 for guix-patches@HIDDEN; Sat, 17 Jul 2021 16:58:27 -0400
Received: from relay9-d.mail.gandi.net ([217.70.183.199]:40743)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brice@HIDDEN>) id 1m4rOD-000707-7N
 for guix-patches@HIDDEN; Sat, 17 Jul 2021 16:58:27 -0400
Received: (Authenticated sender: brice@HIDDEN)
 by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id CA86AFF803
 for <guix-patches@HIDDEN>; Sat, 17 Jul 2021 20:58:21 +0000 (UTC)
From: Brice Waegeneire <brice@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 0/2] Add channels field to guix-configuration
Date: Sat, 17 Jul 2021 22:58:19 +0200
Message-Id: <20210717205819.380-1-brice@HIDDEN>
X-Mailer: git-send-email 2.32.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=217.70.183.199; envelope-from=brice@HIDDEN;
 helo=relay9-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

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





Acknowledgement sent to Brice Waegeneire <brice@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#49610; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 22 Mar 2024 11:00:02 UTC

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