GNU bug report logs - #69940
[PATCH 0/2] Making a 'guix' package with specific channels

Previous Next

Package: guix-patches;

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

Date: Fri, 22 Mar 2024 14:11:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludovic.courtes <at> inria.fr>

Bug is archived. No further changes may be made.

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

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

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


Report forwarded to guix-patches <at> gnu.org:
bug#69940; Package guix-patches. (Fri, 22 Mar 2024 14:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 22 Mar 2024 14:11:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludovic.courtes <at> inria.fr>
Subject: [PATCH 0/2] Making a 'guix' package with specific channels
Date: Fri, 22 Mar 2024 14:58:37 +0100
From: Ludovic Courtès <ludovic.courtes <at> inria.fr>

Hello Guix!

This patch series aims to allow users to create an operating system
that runs a specific Guix for ‘guix-service-type’, and in particular
for /run/current-system/profile/bin/guix: it could be the ‘guix’
channel pinned to a specific revision, or it could be ‘guix’ together
with additional channels.  Here’s the example added in the new
section of the manual:

     (use-modules (guix channels))

     (define my-channels
       ;; Channels that should be available to
       ;; /run/current-system/profile/bin/guix.
       (append
        (list (channel
               (name 'guix-science)
               (url "https://github.com/guix-science/guix-science")
               (branch "master")))
        %default-channels))

     (operating-system
       ;; ...
       (services
         ;; Change the package used by 'guix-service-type'.
         (modify-services %base-services
           (guix-service-type
            config => (guix-configuration
                       (inherit config)
                       (channels my-channels)
                       (guix (guix-for-channels my-channels)))))))

The resulting operating system will have both the ‘guix’ and the
‘guix-science’ channels visible by default.  The ‘channels’ field of
‘guix-configuration’ above ensures that /etc/guix/channels.scm specifies
the same set of channels

Thoughts?

Thanks,
Ludo’.

Ludovic Courtès (2):
  build-system/channel: Add support for additional channels.
  gnu: guix: Define ‘guix-for-channels’ and document its use.

 doc/guix.texi                       | 67 ++++++++++++++++++++++++++++-
 gnu/packages/package-management.scm | 14 +++++-
 guix/build-system/channel.scm       |  7 ++-
 3 files changed, 83 insertions(+), 5 deletions(-)


base-commit: 40f53e8fb5b867e3a1e8fa798328423718282aac
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#69940; Package guix-patches. (Fri, 22 Mar 2024 14:57:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 69940 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludovic.courtes <at> inria.fr>
Subject: [PATCH 2/2] gnu: guix: Define ‘guix-for-channels’ and document its use.
Date: Fri, 22 Mar 2024 15:12:30 +0100
From: Ludovic Courtès <ludovic.courtes <at> inria.fr>

* gnu/packages/package-management.scm (guix-for-channels): New
procedure.
* doc/guix.texi (Customizing the System-Wide Guix): New section.
(Base Services): Add cross-reference.

Change-Id: Ied51c3bf9bf08dfc629bb3f0a152eb20b869a636
---
 doc/guix.texi                       | 62 ++++++++++++++++++++++++++++-
 gnu/packages/package-management.scm | 14 ++++++-
 2 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 07dc6e24a8..a2d5ef3ffd 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5514,6 +5514,7 @@ Channels
 * Specifying Additional Channels::  Extending the package collection.
 * Using a Custom Guix Channel::  Using a customized Guix.
 * Replicating Guix::            Running the @emph{exact same} Guix.
+* Customizing the System-Wide Guix:: Default channels on Guix System.
 * Channel Authentication::      How Guix verifies what it fetches.
 * Channels with Substitutes::   Using channels with available substitutes.
 * Creating a Channel::          How to write your custom channel.
@@ -5671,6 +5672,64 @@ Replicating Guix
 will---some sort of ``meta reproducibility'' capabilities, if you will.
 @xref{Inferiors}, for another way to take advantage of these super powers.
 
+@node Customizing the System-Wide Guix
+@section Customizing the System-Wide Guix
+
+@cindex system-wide Guix, customization
+@cindex channels, for the default Guix
+If you're running Guix System or building system images with it, maybe
+you will want to customize the system-wide @command{guix} it
+provides---specifically, @file{/run/current-system/profile/bin/guix}.
+For example, you might want to provide additional channels or to pin its
+revision.
+
+This can be done using the @code{guix-for-channels} procedure, which
+returns a package for the given channels, and using it as part of your
+operating system configuration, as in this example:
+
+@lisp
+(use-modules (guix channels))
+
+(define my-channels
+  ;; Channels that should be available to
+  ;; /run/current-system/profile/bin/guix.
+  (append
+   (list (channel
+          (name 'guix-science)
+          (url "https://github.com/guix-science/guix-science")
+          (branch "master")))
+   %default-channels))
+
+(operating-system
+  ;; @dots{}
+  (services
+    ;; Change the package used by 'guix-service-type'.
+    (modify-services %base-services
+      (guix-service-type
+       config => (guix-configuration
+                  (inherit config)
+                  (channels my-channels)
+                  (guix (guix-for-channels my-channels)))))))
+@end lisp
+
+The resulting operating system will have both the @code{guix} and the
+@code{guix-science} channels visible by default.  The @code{channels}
+field of @code{guix-configuration} above further ensures that
+@file{/etc/guix/channels.scm}, which is used by @command{guix pull},
+specifies the same set of channels (@pxref{guix-configuration-channels,
+@code{channels} field of @code{guix-configuration}}).
+
+The @code{(gnu packages package-management)} module exports the
+@code{guix-for-channels} procedure, described below.
+
+@deffn {Procedure} guix-for-channels @var{channels}
+Return a package corresponding to @var{channels}.
+
+The result is a ``regular'' package, which can be used in
+@code{guix-configuration} as shown above or in any other place that
+expects a package.
+@end deffn
+
 @node Channel Authentication
 @section Channel Authentication
 
@@ -19734,7 +19793,8 @@ Base Services
 
 @table @asis
 @item @code{guix} (default: @var{guix})
-The Guix package to use.
+The Guix package to use.  @xref{Customizing the System-Wide Guix} to
+learn how to provide a package with a pre-configured set of channels.
 
 @item @code{build-group} (default: @code{"guixbuild"})
 Name of the group for build user accounts.
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index e9dd7427d3..c59f8b2bba 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013-2023 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2013-2024 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2015, 2017, 2020, 2021, 2022, 2023 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2017 Muriithi Frederick Muriuki <fredmanglis <at> gmail.com>
 ;;; Copyright © 2017, 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
@@ -649,6 +649,18 @@ (define-public guix-minimal
       (modify-inputs (package-propagated-inputs guix)
         (delete "guile-ssh"))))))
 
+(define-public (guix-for-channels channels)
+  "Return a package corresponding to CHANNELS."
+  (package
+    (inherit guix)
+    (source (find guix-channel? channels))
+    (build-system channel-build-system)
+    (arguments
+     `(#:channels ,(remove guix-channel? channels)))
+    (inputs '())
+    (native-inputs '())
+    (propagated-inputs '())))
+
 (define-public current-guix-package
   ;; This parameter allows callers to override the package that 'current-guix'
   ;; returns.  This is useful when 'current-guix' cannot compute it by itself,
-- 
2.41.0





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

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 69940 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 1/2] build-system/channel: Add support for additional channels.
Date: Fri, 22 Mar 2024 15:12:29 +0100
Until now, ‘channel-build-system’ would assume a single channel, the
‘guix’ channel.  This change lets users specify additional channels
using the #:channels parameter.

* guix/build-system/channel.scm (build-channels): Add #:channels and
honor it.
(channel-build-system): In ‘lower’, add #:channels and honor it.
* doc/guix.texi (Build Systems): Document it.

Change-Id: I36c1d19cbeee02a4d1144de089b78df0390774a0
---
 doc/guix.texi                 | 5 ++++-
 guix/build-system/channel.scm | 7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index eda4084e7f..07dc6e24a8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10451,7 +10451,10 @@ Build Systems
 name, in which case an additional @code{#:commit} argument must be
 supplied to specify the commit being built (a hexadecimal string).
 
-The resulting package is a Guix instance of the given channel, similar
+Optionally, a @code{#:channels} argument specifying additional channels
+can be provided.
+
+The resulting package is a Guix instance of the given channel(s), similar
 to how @command{guix time-machine} would build it.
 @end defvar
 
diff --git a/guix/build-system/channel.scm b/guix/build-system/channel.scm
index 6ad377f930..0607dcf4d7 100644
--- a/guix/build-system/channel.scm
+++ b/guix/build-system/channel.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2019-2022 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2019-2022, 2024 Ludovic Courtès <ludo <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -37,6 +37,7 @@ (define latest-channel-instances*
 
 (define* (build-channels name inputs
                          #:key source system commit
+                         (channels '())
                          (authenticate? #t)
                          #:allow-other-keys)
   (mlet* %store-monad ((instances
@@ -44,7 +45,7 @@ (define* (build-channels name inputs
                                (return (list source)))
                               ((channel? source)
                                (latest-channel-instances*
-                                (list source)
+                                (cons source channels)
                                 #:authenticate? authenticate?))
                               ((string? source)
                                ;; If SOURCE is a store file name, as is the
@@ -64,12 +65,14 @@ (define* (build-channels name inputs
 (define channel-build-system
   ;; Build system used to "convert" a channel instance to a package.
   (let ((lower (lambda* (name #:key system source commit (authenticate? #t)
+                              (channels '())
                               #:allow-other-keys)
                  (bag
                    (name name)
                    (system system)
                    (build build-channels)
                    (arguments `(#:source ,source
+                                #:channels ,channels
                                 #:authenticate? ,authenticate?
                                 #:commit ,commit))))))
     (build-system (name 'channel)
-- 
2.41.0





Reply sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
You have taken responsibility. (Fri, 05 Apr 2024 16:32:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Fri, 05 Apr 2024 16:32:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: 69940-done <at> debbugs.gnu.org
Subject: Re: [bug#69940] [PATCH 0/2] Making a 'guix' package with specific
 channels
Date: Fri, 05 Apr 2024 18:30:48 +0200
Hello,

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

>   build-system/channel: Add support for additional channels.
>   gnu: guix: Define ‘guix-for-channels’ and document its use.

Pushed as be14d41d9be3ef91d11ab24780855682c432cac9.

Ludo’.




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

This bug report was last modified today.

Previous Next


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