all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Antero Mejr <antero@mailbox.org>
Cc: 49610@debbugs.gnu.org, zimon.toutoune@gmail.com
Subject: [bug#49610] [PATCH v4 1/2] services: guix: Add channels field.
Date: Fri, 22 Mar 2024 11:44:14 +0100	[thread overview]
Message-ID: <87sf0isg01.fsf@gnu.org> (raw)
In-Reply-To: <20230526162606.6747-1-antero@mailbox.org> (Antero Mejr's message of "Fri, 26 May 2023 16:26:05 +0000")

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

Hi Antero,

Antero Mejr <antero@mailbox.org> skribis:

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

Rebased and finally applied!

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

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

Pushed as 883e69cdfd226c8f40b6e3b76ce0740b59857de6.

Thanks!

Ludo’.


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

diff --git a/doc/guix.texi b/doc/guix.texi
index 5c974f2ea4..e419b8d1a4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4727,7 +4727,9 @@ Invoking guix pull
 is passed;
 @item
 the system-wide @file{/etc/guix/channels.scm} file, unless @option{-q}
-is passed;
+is passed (on Guix System, this file can be declared in the operating
+system configuration, @pxref{guix-configuration-channels,
+@code{channels} field of @code{guix-configuration}});
 @item
 the built-in default channels specified in the @code{%default-channels}
 variable.
@@ -19806,10 +19808,11 @@ Base Services
 might want to turn it off for instance in a virtual machine that does
 not need it and where the extra boot time is a problem.
 
+@anchor{guix-configuration-channels}
 @item @code{channels} (default: @code{%default-channels})
-File-like object containing a list of channels to be used by
-@command{guix pull}, by default.  The file-like object is symlinked to
-@file{/etc/guix/channels.scm}.
+List of channels to be specified in @file{/etc/guix/channels.scm}, which
+is what @command{guix pull} uses by default (@pxref{Invoking guix
+pull}).
 
 @quotation Note
 When reconfiguring a system, the existing @file{/etc/guix/channels.scm}
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index dcd66b8064..cd61df718e 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -83,7 +83,7 @@ (define-module (gnu services base)
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
-  #:use-module (guix channels)
+  #:autoload   (guix channels) (%default-channels channel->code)
   #:use-module (guix gexp)
   #:use-module (guix records)
   #:use-module (guix modules)
@@ -98,7 +98,6 @@ (define-module (gnu services base)
   #:use-module (srfi srfi-35)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
-  #:use-module (ice-9 pretty-print)
   #:re-export (user-processes-service-type        ;backwards compatibility
                %default-substitute-urls)
   #:export (fstab-service-type
@@ -1743,17 +1742,13 @@ (define (substitute-key-authorization keys guix)
         ;; Installed the declared ACL.
         (symlink #+default-acl acl-file))))
 
-(define %default-channels-file
-  ;; File-like object containing the default list of channels.
-  (plain-file "channels.scm"
-              (with-output-to-string
-                (lambda _
-                  (pretty-print (map channel->code %default-channels))))))
+(define (install-channels-file channels)
+  "Return a gexp with code to install CHANNELS, a list of channels, in
+/etc/guix/channels.scm."
+  (define channels-file
+    (scheme-file "channels.scm"
+                 `(list ,@(map channel->code channels))))
 
-;; FIXME: Should this gexp be built before boot, like
-;; substitute-key-authorization does?
-(define (install-channels-file channels-file)
-  "Return a gexp with code to install CHANNELS-FILE, a file-like object."
   (with-imported-modules '((guix build utils))
     #~(begin
         (use-modules (guix build utils))
@@ -1828,7 +1823,7 @@ (define-record-type* <guix-configuration>
   (generate-substitute-key? guix-configuration-generate-substitute-key?
                             (default #t))         ;Boolean
   (channels         guix-configuration-channels ;file-like
-                    (default %default-channels-file))
+                    (default %default-channels))
   (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
                       (default '()))
   (max-silent-time  guix-configuration-max-silent-time ;integer
@@ -2040,7 +2035,7 @@ (define (guix-activation config)
               #~#f)
 
         ;; ... and /etc/guix/channels.scm...
-        #$(install-channels-file channels)
+        #$(and channels (install-channels-file channels))
 
         ;; ... and /etc/guix/machines.scm.
         #$(if (guix-build-machines config)

  parent reply	other threads:[~2024-03-22 10:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17 20:58 [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Brice Waegeneire
2021-07-17 21:04 ` [bug#49610] [PATCH 1/2] services: guix: Use "match-record" in activation Brice Waegeneire
2021-07-21 21:47   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Ludovic Courtès
2021-08-04  4:42     ` Brice Waegeneire
2021-07-17 21:04 ` [bug#49610] [PATCH 2/2] services: guix: Add channels field Brice Waegeneire
2021-07-21 21:53   ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Ludovic Courtès
2021-09-01 21:16     ` Ludovic Courtès
2021-12-21 21:00     ` [bug#49610] [PATCH v2] sevices: guix: Add channels field Brice Waegeneire
2022-01-03 11:32       ` Ludovic Courtès
2023-05-25 20:12 ` [bug#49610] [PATCH v3] services: " Antero Mejr via Guix-patches via
2023-05-26 10:40   ` Simon Tournier
2023-05-26 16:29     ` Antero Mejr via Guix-patches via
2023-05-26 16:26 ` [bug#49610] [PATCH v4 1/2] " Antero Mejr via Guix-patches via
2023-05-26 16:26   ` [bug#49610] [PATCH v4 2/2] doc: guix.texi: Clarify wording in Channels section Antero Mejr via Guix-patches via
2024-03-22 10:45     ` Ludovic Courtès
2024-03-22 10:44   ` Ludovic Courtès [this message]
2024-03-24 10:24 ` [bug#49610] [PATCH 0/2] Add channels field to guix-configuration Franz Geffke
2024-04-04  8:03   ` Simon Tournier
2024-04-09  8:44     ` Franz Geffke

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

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

  git send-email \
    --in-reply-to=87sf0isg01.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=49610@debbugs.gnu.org \
    --cc=antero@mailbox.org \
    --cc=zimon.toutoune@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.