From patchwork Fri Mar 22 10:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 62125 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D747627BBE9; Fri, 22 Mar 2024 10:54:20 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 46C0827BBE2 for ; Fri, 22 Mar 2024 10:54:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rncWb-0000eQ-D7; Fri, 22 Mar 2024 06:53:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rncWY-0000c3-6m for guix-patches@gnu.org; Fri, 22 Mar 2024 06:53:22 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rncWX-000518-V9 for guix-patches@gnu.org; Fri, 22 Mar 2024 06:53:21 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rncXC-0001Wk-2N for guix-patches@gnu.org; Fri, 22 Mar 2024 06:54:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49610] [PATCH v4 1/2] services: guix: Add channels field. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Mar 2024 10:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49610 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Antero Mejr Cc: 49610@debbugs.gnu.org, zimon.toutoune@gmail.com Received: via spool by 49610-submit@debbugs.gnu.org id=B49610.17111048395839 (code B ref 49610); Fri, 22 Mar 2024 10:54:02 +0000 Received: (at 49610) by debbugs.gnu.org; 22 Mar 2024 10:53:59 +0000 Received: from localhost ([127.0.0.1]:42559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rncX8-0001W0-HN for submit@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 ) id 1rncX2-0001Ul-Jo for 49610@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 ) 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: Ludovic =?utf-8?q?Court=C3=A8s?= In-Reply-To: <20230526162606.6747-1-antero@mailbox.org> (Antero Mejr's message of "Fri, 26 May 2023 16:26:05 +0000") References: <20210717205819.380-1-brice@waegenei.re> <20230526162606.6747-1-antero@mailbox.org> Date: Fri, 22 Mar 2024 11:44:14 +0100 Message-ID: <87sf0isg01.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi Antero, Antero Mejr 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’. 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* (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)