From patchwork Thu Aug 17 10:17:29 2023 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: 52954 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 14B0A27BBEA; Thu, 17 Aug 2023 11:18:15 +0100 (BST) 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=unavailable 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 7317027BBE9 for ; Thu, 17 Aug 2023 11:18:13 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWa4u-00069e-Kt; Thu, 17 Aug 2023 06:18:08 -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 1qWa4t-000690-40 for guix-patches@gnu.org; Thu, 17 Aug 2023 06:18:07 -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 1qWa4s-0003T0-4G; Thu, 17 Aug 2023 06:18:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qWa4n-0001CY-Oi; Thu, 17 Aug 2023 06:18:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 17 Aug 2023 10:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65229 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65229@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Simon Tournier , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 65229-submit@debbugs.gnu.org id=B65229.16922674734598 (code B ref 65229); Thu, 17 Aug 2023 10:18:01 +0000 Received: (at 65229) by debbugs.gnu.org; 17 Aug 2023 10:17:53 +0000 Received: from localhost ([127.0.0.1]:42811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWa4e-0001C4-C2 for submit@debbugs.gnu.org; Thu, 17 Aug 2023 06:17:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40778) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWa4b-0001Bl-Rh for 65229@debbugs.gnu.org; Thu, 17 Aug 2023 06:17:51 -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 1qWa4W-0003J8-Lt; Thu, 17 Aug 2023 06:17:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=UsNaWrHkHvq2DGiBtv4CJgFaBdffIekK95+sMIK99tg=; b=HEi0M28h/AksKaR012nv aPYIC961Njxdqh4nwWeWdG0QzUaHzRAgYFog2XWkyMNzeigPu5JfJ/Svw4OnOaweDkZLeASacdqmQ 0fZ3YSF2LupU3F2Epq699NAjEDjMHgnBW5HlvrUWcE0CAfejs1aDG2+qPqHofGRNUG7xJL+PmW9Ly smnrDp+YvPhEaW8HYs12lMSEQcfgtIcjh5U7AYxzKF1HscCpf5homnfEFgACOzkWrZkWn/9HNOcLL kJcjPfSiwjT/qyNKOLTfHiT8HUl+PQBD1YwzFxQilVUcbMkkA7FRGm88MDORg9YMGMgFw0WCYn142 MdD83YKHchGMUw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 17 Aug 2023 12:17:29 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <875y5eyrl0.fsf@gnu.org> References: <875y5eyrl0.fsf@gnu.org> 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 From: Ludovic Courtès This also fixes . * guix/scripts/pull.scm (show-help, %options): Add '-q'. (channel-list): Honor it. * guix/scripts/time-machine.scm (show-help, %options): Add '-q'. * doc/guix.texi (Invoking guix pull, Invoking guix time-machine): Document it. Reported-by: Simon Tournier --- doc/guix.texi | 47 +++++++++++++++++++++++++++-------- guix/scripts/pull.scm | 15 +++++++++-- guix/scripts/time-machine.scm | 8 +++++- 3 files changed, 57 insertions(+), 13 deletions(-) Changes since v1: • Add ‘--no-channel-files’. • Join the two ‘time-machine’ examples, the one without ‘-q’ and the one with ‘-q’ (I realized there was already one example without ‘-q’ so I figured it was easier to clarify ‘channels.scm’ handling upfront). • Document the <(echo %default-channels) trick. Let me know what you think! Ludo’. diff --git a/doc/guix.texi b/doc/guix.texi index 633d62bd98..2d54b92fa5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4802,9 +4802,11 @@ Invoking guix pull @item the @option{--channels} option; @item -the user's @file{~/.config/guix/channels.scm} file; +the user's @file{~/.config/guix/channels.scm} file, unless @option{-q} +is passed; @item -the system-wide @file{/etc/guix/channels.scm} file; +the system-wide @file{/etc/guix/channels.scm} file, unless @option{-q} +is passed; @item the built-in default channels specified in the @code{%default-channels} variable. @@ -4906,6 +4908,11 @@ Invoking guix pull evaluates to a list of channel objects. @xref{Channels}, for more information. +@item --no-channel-files +@itemx -q +Inhibit loading of the user and system channel files, +@file{~/.config/guix/channels.scm} and @file{/etc/guix/channels.scm}. + @cindex channel news @item --news @itemx -N @@ -5051,7 +5058,9 @@ Invoking guix time-machine environment -C --ad-hoc guile -- guile @end example -The command above fetches Guix@tie{}1.2.0 and runs its @command{guix +The command above fetches Guix@tie{}1.2.0 (and possibly other channels +specified by your @file{channels.scm} configuration files---see +below) and runs its @command{guix environment} command to spawn an environment in a container running @command{guile} (@command{guix environment} has since been subsumed by @command{guix shell}; @pxref{Invoking guix shell}). It's like driving a @@ -5061,6 +5070,21 @@ Invoking guix time-machine large number of packages; the result is cached though and subsequent commands targeting the same commit are almost instantaneous. +As for @command{guix pull}, in the absence of any options, +@command{time-machine} fetches the latest commits of the channels +specified in @file{~/.config/guix/channels.scm}, +@file{/etc/guix/channels.scm}, or the default channels; the @option{-q} +option lets you ignore these configuration files. The command: + +@example +guix time-machine -q -- build hello +@end example + +will thus build the package @code{hello} as defined in the main branch +of Guix, without any additional channel, which is in general a newer +revision of Guix than you have installed. Time travel works in both +directions! + @quotation Note The history of Guix is immutable and @command{guix time-machine} provides the exact same software as they are in a specific Guix @@ -5093,18 +5117,21 @@ Invoking guix time-machine Read the list of channels from @var{file}. @var{file} must contain Scheme code that evaluates to a list of channel objects. @xref{Channels} for more information. -@end table -As for @command{guix pull}, the absence of any options means that the -latest commit on the master branch will be used. The command +@item --no-channel-files +@itemx -q +Inhibit loading of the user and system channel files, +@file{~/.config/guix/channels.scm} and @file{/etc/guix/channels.scm}. + +Thus, @command{guix time-machine -q} is equivalent to the following Bash +command, using the ``process substitution'' syntax (@pxref{Process +Substitution,,, bash, The GNU Bash Reference Manual}): @example -guix time-machine -- build hello +guix time-machine -C <(echo %default-channels) @dots{} @end example -will thus build the package @code{hello} as defined in the master branch, -which is in general a newer revision of Guix than you have installed. -Time travel works in both directions! +@end table Note that @command{guix time-machine} can trigger builds of channels and their dependencies, and these are controlled by the standard build diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index ecd264d3fa..3a8dd6ea01 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -84,6 +84,9 @@ (define (show-help) Download and deploy the latest version of Guix.\n")) (display (G_ " -C, --channels=FILE deploy the channels defined in FILE")) + (display (G_ " + -q, --no-channel-files + inhibit loading of user and system 'channels.scm'")) (display (G_ " --url=URL download \"guix\" channel from the Git repository at URL")) (display (G_ " @@ -133,6 +136,9 @@ (define %options (cons* (option '(#\C "channels") #t #f (lambda (opt name arg result) (alist-cons 'channel-file arg result))) + (option '(#\q "no-channel-files") #f #f + (lambda (opt name arg result) + (alist-cons 'ignore-channel-files? #t result))) (option '(#\l "list-generations") #f #t (lambda (opt name arg result) (cons `(query list-generations ,arg) @@ -735,6 +741,9 @@ (define (channel-list opts) (define file (assoc-ref opts 'channel-file)) + (define ignore-channel-files? + (assoc-ref opts 'ignore-channel-files?)) + (define default-file (string-append (config-directory) "/channels.scm")) @@ -750,9 +759,11 @@ (define (channel-list opts) (define channels (cond (file (load-channels file)) - ((file-exists? default-file) + ((and (not ignore-channel-files?) + (file-exists? default-file)) (load-channels default-file)) - ((file-exists? global-file) + ((and (not ignore-channel-files?) + (file-exists? global-file)) (load-channels global-file)) (else %default-channels))) diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm index d7c71ef705..fa12e6f170 100644 --- a/guix/scripts/time-machine.scm +++ b/guix/scripts/time-machine.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Konrad Hinsen -;;; Copyright © 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2019, 2020, 2021, 2023 Ludovic Courtès ;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. @@ -51,6 +51,9 @@ (define (show-help) Execute COMMAND ARGS... in an older version of Guix.\n")) (display (G_ " -C, --channels=FILE deploy the channels defined in FILE")) + (display (G_ " + -q, --no-channel-files + inhibit loading of user and system 'channels.scm'")) (display (G_ " --url=URL use the Git repository at URL")) (display (G_ " @@ -75,6 +78,9 @@ (define %options (cons* (option '(#\C "channels") #t #f (lambda (opt name arg result) (alist-cons 'channel-file arg result))) + (option '(#\q "no-channel-files") #f #f + (lambda (opt name arg result) + (alist-cons 'ignore-channel-files? #t result))) (option '("url") #t #f (lambda (opt name arg result) (alist-cons 'repository-url arg