From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KP9ENA9G82BzAgEAgWs5BA (envelope-from ) for ; Sat, 17 Jul 2021 23:05:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id OJfiLw9G82ChfwAA1q6Kng (envelope-from ) for ; Sat, 17 Jul 2021 21:05:19 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 429B71BE3B for ; Sat, 17 Jul 2021 23:05:19 +0200 (CEST) Received: from localhost ([::1]:34016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4rUs-0001lR-8p for larch@yhetil.org; Sat, 17 Jul 2021 17:05:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4rUc-0001aS-ED for guix-patches@gnu.org; Sat, 17 Jul 2021 17:05:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4rUc-00030v-6T for guix-patches@gnu.org; Sat, 17 Jul 2021 17:05:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m4rUc-0007tw-2c for guix-patches@gnu.org; Sat, 17 Jul 2021 17:05:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49610] [PATCH 2/2] services: guix: Add channels field. Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 17 Jul 2021 21:05: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: 49610@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162655588730340 (code B ref -1); Sat, 17 Jul 2021 21:05:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jul 2021 21:04:47 +0000 Received: from localhost ([127.0.0.1]:54688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4rUI-0007tD-Mc for submit@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 ) id 1m4rUC-0007sv-UL for submit@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 ) id 1m4rUC-0001a0-Oo for guix-patches@gnu.org; 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 ) id 1m4rU7-0002ep-CJ for guix-patches@gnu.org; Sat, 17 Jul 2021 17:04:36 -0400 Received: (Authenticated sender: brice@waegenei.re) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 68722FF803 for ; Sat, 17 Jul 2021 21:04:28 +0000 (UTC) From: Brice Waegeneire Date: Sat, 17 Jul 2021 23:04:24 +0200 Message-Id: <20210717210424.1921-2-brice@waegenei.re> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717205819.380-1-brice@waegenei.re> References: <20210717205819.380-1-brice@waegenei.re> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.70.183.199; envelope-from=brice@waegenei.re; 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-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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1626555919; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=3mUWudHQurleWaLNxpO5sqNLKto0NnO1+7IoiMlM9zk=; b=tuILE65E3S3cEK/pWcpAJQk491J+KuEyijUB2dXBcY6B59aPGWifrVAblk1bRdG72peKym mGQySsNaj8SlJl96SZ2BNnesptU5NCdaEA59S6cRE8a7dLVHJT7urbkLakas3f2o4fuNIM hBMwSpzQnEspsiN5pdGgRRJmdjiYL2FHmeYL5dgBXaAinpWPc8XFtDlsK414w3h0QASTFx DMJDxZR0Hy+sBRd6sZQw5EnV0vOyZJvXndmUyAuSC7rfxXpaNjSA5c6znK2aeVwuuDGTz6 VqV9aPQQolucK+kVNzFsr7zbrX5WK00kBSeTdaZQ+W7V1vtxYyOjG/YdqCOjlA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1626555919; a=rsa-sha256; cv=none; b=OqJhjL+sqkmhAPSrwOf1RorfCMP3qV67h+kkRy87Z3p9YhkzHy7ShD/4I93A6sY7RDEVfv 7n5gJ8kJlbKU3R1GkJZlFtWrRC3YoVB8Qd39vER9sMIJ1aOgprwIacP4/RGCSwHVrv5DMl RgjtRYA5pmAKZ6h8xYbLr+K7cBFWQjwcqHyj2z1VHdIWLxHeRR8/mZZg13pkHjitRuanCR Jlrka1rmUG5vrdHIhNb3UpSn61ndN8IoG2Gmrn03TOHRWJGPEAeYt5mf/jNm+iqBgxjcxc dhfInw00DrXcZ7mPLRH2/U1H7kRfrrEGah9TngSmnhylFv1I0jLr1a7P0NFBRg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 2.59 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 429B71BE3B X-Spam-Score: 2.59 X-Migadu-Scanner: scn0.migadu.com X-TUID: qLi1ESvO0HjL * 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 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