unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 69940@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludovic.courtes@inria.fr>
Subject: [bug#69940] [PATCH 2/2] gnu: guix: Define ‘guix-for-channels’ and document its use.
Date: Fri, 22 Mar 2024 15:12:30 +0100	[thread overview]
Message-ID: <58fefa1f778d9ead96b669ac258ec978f79d1da2.1711115625.git.ludo@gnu.org> (raw)
In-Reply-To: <cover.1711115625.git.ludo@gnu.org>

From: Ludovic Courtès <ludovic.courtes@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@gnu.org>
+;;; Copyright © 2013-2024 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015, 2017, 2020, 2021, 2022, 2023 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017 Muriithi Frederick Muriuki <fredmanglis@gmail.com>
 ;;; Copyright © 2017, 2018 Oleg Pykhalov <go.wigust@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





  parent reply	other threads:[~2024-03-22 14:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 13:58 [bug#69940] [PATCH 0/2] Making a 'guix' package with specific channels Ludovic Courtès
2024-03-22 14:12 ` [bug#69940] [PATCH 1/2] build-system/channel: Add support for additional channels Ludovic Courtès
2024-03-22 14:12 ` Ludovic Courtès [this message]
2024-04-05 16:30 ` bug#69940: [PATCH 0/2] Making a 'guix' package with specific channels Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58fefa1f778d9ead96b669ac258ec978f79d1da2.1711115625.git.ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=69940@debbugs.gnu.org \
    --cc=ludovic.courtes@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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