* [bug#65229] [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes
@ 2023-08-11 15:31 Ludovic Courtès
2023-08-11 15:34 ` [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
2023-08-11 15:34 ` [bug#65229] [PATCH 2/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
0 siblings, 2 replies; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-11 15:31 UTC (permalink / raw)
To: 65229
Cc: maurice.bremond, Ludovic Courtès, Christopher Baines,
Josselin Poiret, Ludovic Courtès, Mathieu Othacehe,
Ricardo Wurmus, Simon Tournier, Tobias Geerinckx-Rice
Hello!
These patches address two related issues:
• The first one adds ‘-q’ to ‘pull’ and ‘time-machine’ to
instruct them to ignore the user/system ‘channels.scm’ file.
That way, a command like the following is guaranteed to have
the same semantics regardless of available config files:
guix time-machine -q --commit=v1.2.0 -- build hello
This issue had been raised in
<https://issues.guix.gnu.org/63726>.
• The second one lets users do things (in Bash) like:
guix time-machine -C <(echo %default-channels) -- …
Feedback welcome!
Ludo’.
Ludovic Courtès (2):
pull, time-machine: Add '-q' to ignore channel files.
ui: 'load*' accepts /dev/fd/N files pointing to a pipe.
doc/guix.texi | 30 ++++++++++++++++++++++--------
guix/scripts/pull.scm | 14 ++++++++++++--
guix/scripts/time-machine.scm | 7 ++++++-
guix/ui.scm | 16 +++++++++++++++-
tests/guix-build.sh | 9 ++++++++-
5 files changed, 63 insertions(+), 13 deletions(-)
base-commit: 56fddefc6de3b0c1f2ccb9559d86ba08d2e429b9
--
2.41.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-11 15:31 [bug#65229] [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes Ludovic Courtès
@ 2023-08-11 15:34 ` Ludovic Courtès
2023-08-16 12:59 ` Simon Tournier
2023-08-11 15:34 ` [bug#65229] [PATCH 2/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
1 sibling, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-11 15:34 UTC (permalink / raw)
To: 65229
Cc: maurice.bremond, Ludovic Courtès, Simon Tournier,
Christopher Baines, Josselin Poiret, Ludovic Courtès,
Mathieu Othacehe, Ricardo Wurmus, Simon Tournier,
Tobias Geerinckx-Rice
From: Ludovic Courtès <ludovic.courtes@inria.fr>
This also fixes <https://issues.guix.gnu.org/63726>.
* 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 <zimon.toutoune@gmail.com>
---
doc/guix.texi | 30 ++++++++++++++++++++++--------
guix/scripts/pull.scm | 14 ++++++++++++--
guix/scripts/time-machine.scm | 7 ++++++-
3 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 409ca2ad62..ec36159de1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4801,9 +4801,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.
@@ -4905,6 +4907,10 @@ Invoking guix pull
evaluates to a list of channel objects. @xref{Channels}, for more
information.
+@item -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
@@ -5092,18 +5098,26 @@ 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.
+
+@item -q
+Inhibit loading of the user and system channel files,
+@file{~/.config/guix/channels.scm} and @file{/etc/guix/channels.scm}.
@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
+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 -- build hello
+guix time-machine -q -- build hello
@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!
+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!
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..f0d4ff36e6 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -84,6 +84,8 @@ (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 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 +135,9 @@ (define %options
(cons* (option '(#\C "channels") #t #f
(lambda (opt name arg result)
(alist-cons 'channel-file arg result)))
+ (option '(#\q) #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 +740,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 +758,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..8afea6b35d 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 <konrad.hinsen@fastmail.net>
-;;; Copyright © 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019, 2020, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -51,6 +51,8 @@ (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 inhibit loading of user and system 'channels.scm'"))
(display (G_ "
--url=URL use the Git repository at URL"))
(display (G_ "
@@ -75,6 +77,9 @@ (define %options
(cons* (option '(#\C "channels") #t #f
(lambda (opt name arg result)
(alist-cons 'channel-file arg result)))
+ (option '(#\q) #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
--
2.41.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 2/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe.
2023-08-11 15:31 [bug#65229] [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes Ludovic Courtès
2023-08-11 15:34 ` [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
@ 2023-08-11 15:34 ` Ludovic Courtès
2023-08-16 13:32 ` Simon Tournier
1 sibling, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-11 15:34 UTC (permalink / raw)
To: 65229
Cc: maurice.bremond, Ludovic Courtès, Christopher Baines,
Josselin Poiret, Ludovic Courtès, Mathieu Othacehe,
Ricardo Wurmus, Simon Tournier, Tobias Geerinckx-Rice
From: Ludovic Courtès <ludovic.courtes@inria.fr>
This allows users to write Bash commands like:
guix time-machine -C <(echo %default-channels) -- ...
or:
guix build -m <(echo '(specifications->manifest (list "guile"))')
Previously, on GNU/Linux, they would fail with:
error: failed to load '/dev/fd/63': No such file or directory
* guix/ui.scm (try-canonicalize-path): New procedure.
(load*): Use it.
* tests/guix-build.sh: Test 'guix build -m' with a /dev/fd/N file.
---
guix/ui.scm | 16 +++++++++++++++-
tests/guix-build.sh | 9 ++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 47a118364a..6f2d4fe245 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -200,6 +200,20 @@ (define-syntax-rule (without-compiler-optimizations exp)
(parameterize (((@ (system base compile) default-optimization-level) 1))
exp))
+(define (try-canonicalize-path file)
+ "Like 'canonicalize-path', but return FILE as-is if 'canonicalize-path'
+throws.
+
+This is necessary for corner cases where 'canonicalize-path' fails. One
+example is on Linux when a /dev/fd/N file denotes a pipe, represented as a
+symlink to a non-existent file like 'pipe:[1234]', as in this example:
+
+ sh -c 'stat $(readlink -f /dev/fd/1)' | cat"
+ (catch 'system-error
+ (lambda ()
+ (canonicalize-path file))
+ (const file)))
+
(define* (load* file user-module
#:key (on-error 'nothing-special))
"Load the user provided Scheme source code FILE."
@@ -230,7 +244,7 @@ (define* (load* file user-module
;; 'primitive-load', so that FILE is compiled, which then allows
;; us to provide better error reporting with source line numbers.
(without-compiler-optimizations
- (load (canonicalize-path file))))
+ (load (try-canonicalize-path file))))
(const #f))))))
(lambda _
;; XXX: Errors are reported from the pre-unwind handler below, but
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 317c58ac42..4eab0e38b6 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2012-2014, 2016-2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012-2014, 2016-2023 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
#
@@ -397,6 +397,13 @@ guix build -d -m "$module_dir/manifest.scm" \
rm "$module_dir"/*.scm
+if [ -n "$BASH_VERSION" ]
+then
+ # Check whether we can load from a /dev/fd/N denoting a pipe, using this
+ # handy Bash-specific construct.
+ guix build -m <(echo '(specifications->manifest (list "guile"))') -n
+fi
+
# Using 'GUIX_BUILD_OPTIONS'.
GUIX_BUILD_OPTIONS="--dry-run --no-grafts"
export GUIX_BUILD_OPTIONS
--
2.41.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-11 15:34 ` [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
@ 2023-08-16 12:59 ` Simon Tournier
2023-08-16 13:43 ` Simon Tournier
2023-08-17 8:56 ` Ludovic Courtès
0 siblings, 2 replies; 12+ messages in thread
From: Simon Tournier @ 2023-08-16 12:59 UTC (permalink / raw)
To: Ludovic Courtès, 65229
Cc: Josselin Poiret, Tobias Geerinckx-Rice, maurice.bremond,
Mathieu Othacehe, Ludovic Courtès, Christopher Baines,
Ricardo Wurmus, Ludovic Courtès
Hi Ludo,
Cool addition!
On Fri, 11 Aug 2023 at 17:34, Ludovic Courtès <ludo@gnu.org> wrote:
> -As for @command{guix pull}, the absence of any options means that the
> -latest commit on the master branch will be used. The command
> +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 -- build hello
> +guix time-machine -q -- build hello
> @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!
> +will thus build the package @code{hello} as defined in the main branch
Why not the master branch? Is the branch renamed from ’master’ to
’main’? If not, I would keep the explicit master branch in order to
avoid confusion.
> +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!
Well, I would keep the previous example because the behaviour appears to
me more prone-error. I mean, by default, there is no channels.scm file
under ~/.config/guix/ or /etc/guix, therefore an explanation of the
behaviour without any option at all appears to me worth. Moreover,
since there is no channels.scm file by default, i.e., the default is
%default-channels, it appears to me weird to explain the specific
behaviour (without any option and reaching new revision) using an option
turning off the channels.scm file.
> diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
> + (display (G_ "
> + -q inhibit loading of user and system 'channels.scm'"))
[...]
> diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm
> + (display (G_ "
> + -q inhibit loading of user and system 'channels.scm'"))
No long option? As --no-channel-files or --ignore-channel-files ?
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 2/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe.
2023-08-11 15:34 ` [bug#65229] [PATCH 2/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
@ 2023-08-16 13:32 ` Simon Tournier
0 siblings, 0 replies; 12+ messages in thread
From: Simon Tournier @ 2023-08-16 13:32 UTC (permalink / raw)
To: Ludovic Courtès, 65229
Cc: Josselin Poiret, Tobias Geerinckx-Rice, maurice.bremond,
Mathieu Othacehe, Ludovic Courtès, Christopher Baines,
Ricardo Wurmus, Ludovic Courtès
Hi Ludo,
Cool!
On Fri, 11 Aug 2023 at 17:34, Ludovic Courtès <ludo@gnu.org> wrote:
> This allows users to write Bash commands like:
>
> guix time-machine -C <(echo %default-channels) -- ...
>
> or:
>
> guix build -m <(echo '(specifications->manifest (list "guile"))')
I propose to document this. WDYT about this?
--8<---------------cut here---------------start------------->8---
1 file changed, 6 insertions(+)
doc/guix.texi | 6 ++++++
modified doc/guix.texi
@@ -5103,6 +5103,12 @@ Invoking guix time-machine
@item -q
Inhibit loading of the user and system channel files,
@file{~/.config/guix/channels.scm} and @file{/etc/guix/channels.scm}.
+
+This option is equivalent to the command run on Bash shell:
+
+@example
+guix time-machine -C <(echo %default-channels) -- build hello
+@end example
@end table
As for @command{guix pull}, in the absence of any options,
--8<---------------cut here---------------end--------------->8---
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-16 12:59 ` Simon Tournier
@ 2023-08-16 13:43 ` Simon Tournier
2023-08-17 8:56 ` Ludovic Courtès
1 sibling, 0 replies; 12+ messages in thread
From: Simon Tournier @ 2023-08-16 13:43 UTC (permalink / raw)
To: Ludovic Courtès, 65229
Cc: Josselin Poiret, Tobias Geerinckx-Rice, maurice.bremond,
Mathieu Othacehe, Ludovic Courtès, Christopher Baines,
Ricardo Wurmus, Ludovic Courtès
Re,
On Wed, 16 Aug 2023 at 14:59, Simon Tournier <zimon.toutoune@gmail.com> wrote:
> Well, I would keep the previous example because the behaviour appears to
> me more prone-error. I mean, by default, there is no channels.scm file
> under ~/.config/guix/ or /etc/guix, therefore an explanation of the
> behaviour without any option at all appears to me worth. Moreover,
> since there is no channels.scm file by default, i.e., the default is
> %default-channels, it appears to me weird to explain the specific
> behaviour (without any option and reaching new revision) using an option
> turning off the channels.scm file.
Somehow, I would keep something like [1]:
--8<---------------cut here---------------start------------->8---
Similarly as @command{guix pull}, the absence of any options means that
either the user's @file{~/.config/guix/channels.scm} file, or either the
system-wide @file{/etc/guix/channels.scm} file, or either the built-in
default channels specified in the @code{%default-channels} will be
honored, in that order. The command
@example
guix time-machine -- build hello
@end example
will thus build the package @code{hello} as defined by the previous
@dfn{channels} file (@pxref{Channels}). In general, it builds a newer
revision of Guix than you have installed. Time travel works in both
directions!
--8<---------------cut here---------------end--------------->8---
1: https://yhetil.org/guix/87r0qyrlm0.fsf@gmail.com
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-16 12:59 ` Simon Tournier
2023-08-16 13:43 ` Simon Tournier
@ 2023-08-17 8:56 ` Ludovic Courtès
2023-08-17 9:59 ` Simon Tournier
` (2 more replies)
1 sibling, 3 replies; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-17 8:56 UTC (permalink / raw)
To: Simon Tournier
Cc: Tobias Geerinckx-Rice, Josselin Poiret, 65229, maurice.bremond,
Mathieu Othacehe, Christopher Baines, Ricardo Wurmus
Hi,
Simon Tournier <zimon.toutoune@gmail.com> skribis:
> On Fri, 11 Aug 2023 at 17:34, Ludovic Courtès <ludo@gnu.org> wrote:
[...]
>> -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!
>> +will thus build the package @code{hello} as defined in the main branch
>
> Why not the master branch? Is the branch renamed from ’master’ to
> ’main’? If not, I would keep the explicit master branch in order to
> avoid confusion.
The “main branch” is the branch currently called ‘master’ (I think we
should rename it to ‘main’ eventually, but I’d have written @code{main}
if I wanted to imply it’s called that way).
>> +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!
>
> Well, I would keep the previous example because the behaviour appears to
> me more prone-error. I mean, by default, there is no channels.scm file
> under ~/.config/guix/ or /etc/guix, therefore an explanation of the
> behaviour without any option at all appears to me worth. Moreover,
> since there is no channels.scm file by default, i.e., the default is
> %default-channels, it appears to me weird to explain the specific
> behaviour (without any option and reaching new revision) using an option
> turning off the channels.scm file.
I thought that we cannot easily describe what ‘guix time-machine --
build hello’ does, precisely because it depends on whether
‘channels.scm’ files are present and on what they do. Conversely,
explaining what happens with ‘-q’ is trivial because it doesn’t depend
on external state.
Anyway, I’ll try and reword that.
>> diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
>
>> + (display (G_ "
>> + -q inhibit loading of user and system 'channels.scm'"))
>
> [...]
>
>> diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm
>
>> + (display (G_ "
>> + -q inhibit loading of user and system 'channels.scm'"))
>
> No long option? As --no-channel-files or --ignore-channel-files ?
Yeah, I thought we’d follow ‘guix repl’ and ‘guile’, which have no long
option, but maybe we should add ‘--no-channel-files’.
Thanks you; I’ll send a new version.
Ludo’.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-17 8:56 ` Ludovic Courtès
@ 2023-08-17 9:59 ` Simon Tournier
2023-08-17 10:17 ` [bug#65229] [PATCH v2 1/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
2023-08-17 10:17 ` [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
2 siblings, 0 replies; 12+ messages in thread
From: Simon Tournier @ 2023-08-17 9:59 UTC (permalink / raw)
To: Ludovic Courtès
Cc: Tobias Geerinckx-Rice, Josselin Poiret, 65229, maurice.bremond,
Mathieu Othacehe, Christopher Baines, Ricardo Wurmus
Hi Ludo,
On Thu, 17 Aug 2023 at 10:57, Ludovic Courtès <ludo@gnu.org> wrote:
> >> -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!
> >> +will thus build the package @code{hello} as defined in the main branch
> >
> > Why not the master branch? Is the branch renamed from ’master’ to
> > ’main’? If not, I would keep the explicit master branch in order to
> > avoid confusion.
>
> The “main branch” is the branch currently called ‘master’ (I think we
> should rename it to ‘main’ eventually, but I’d have written @code{main}
> if I wanted to imply it’s called that way).
I think the term "main branch" is confusing because many forges as
Gitlab propose by default to rename from @code{master} to
@code{main}. Well, if instead of @code{main}, these forges were
proposing @code{trunk} or @code{primary} or whatever else, it would be
fine.
Therefore, I propose the wording:
defined in the main branch of Guix (currently called @code{master}), without
any additional channel, [...]
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH v2 1/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe.
2023-08-17 8:56 ` Ludovic Courtès
2023-08-17 9:59 ` Simon Tournier
@ 2023-08-17 10:17 ` Ludovic Courtès
2023-08-17 10:17 ` [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
2 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-17 10:17 UTC (permalink / raw)
To: 65229
Cc: Ludovic Courtès, Christopher Baines, Josselin Poiret,
Ludovic Courtès, Mathieu Othacehe, Ricardo Wurmus,
Simon Tournier, Tobias Geerinckx-Rice
From: Ludovic Courtès <ludovic.courtes@inria.fr>
This allows users to write Bash commands like:
guix time-machine -C <(echo %default-channels) -- ...
or:
guix build -m <(echo '(specifications->manifest (list "guile"))')
Previously, on GNU/Linux, they would fail with:
error: failed to load '/dev/fd/63': No such file or directory
* guix/ui.scm (try-canonicalize-path): New procedure.
(load*): Use it.
* tests/guix-build.sh: Test 'guix build -m' with a /dev/fd/N file.
---
guix/ui.scm | 16 +++++++++++++++-
tests/guix-build.sh | 9 ++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 47a118364a..6f2d4fe245 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -200,6 +200,20 @@ (define-syntax-rule (without-compiler-optimizations exp)
(parameterize (((@ (system base compile) default-optimization-level) 1))
exp))
+(define (try-canonicalize-path file)
+ "Like 'canonicalize-path', but return FILE as-is if 'canonicalize-path'
+throws.
+
+This is necessary for corner cases where 'canonicalize-path' fails. One
+example is on Linux when a /dev/fd/N file denotes a pipe, represented as a
+symlink to a non-existent file like 'pipe:[1234]', as in this example:
+
+ sh -c 'stat $(readlink -f /dev/fd/1)' | cat"
+ (catch 'system-error
+ (lambda ()
+ (canonicalize-path file))
+ (const file)))
+
(define* (load* file user-module
#:key (on-error 'nothing-special))
"Load the user provided Scheme source code FILE."
@@ -230,7 +244,7 @@ (define* (load* file user-module
;; 'primitive-load', so that FILE is compiled, which then allows
;; us to provide better error reporting with source line numbers.
(without-compiler-optimizations
- (load (canonicalize-path file))))
+ (load (try-canonicalize-path file))))
(const #f))))))
(lambda _
;; XXX: Errors are reported from the pre-unwind handler below, but
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 317c58ac42..4eab0e38b6 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2012-2014, 2016-2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012-2014, 2016-2023 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
#
@@ -397,6 +397,13 @@ guix build -d -m "$module_dir/manifest.scm" \
rm "$module_dir"/*.scm
+if [ -n "$BASH_VERSION" ]
+then
+ # Check whether we can load from a /dev/fd/N denoting a pipe, using this
+ # handy Bash-specific construct.
+ guix build -m <(echo '(specifications->manifest (list "guile"))') -n
+fi
+
# Using 'GUIX_BUILD_OPTIONS'.
GUIX_BUILD_OPTIONS="--dry-run --no-grafts"
export GUIX_BUILD_OPTIONS
base-commit: 1bd44b425b79e9da160b33a9b19d01973b44772e
--
2.41.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-17 8:56 ` Ludovic Courtès
2023-08-17 9:59 ` Simon Tournier
2023-08-17 10:17 ` [bug#65229] [PATCH v2 1/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
@ 2023-08-17 10:17 ` Ludovic Courtès
2023-08-17 11:20 ` Simon Tournier
2 siblings, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-17 10:17 UTC (permalink / raw)
To: 65229
Cc: Ludovic Courtès, Simon Tournier, Christopher Baines,
Josselin Poiret, Ludovic Courtès, Mathieu Othacehe,
Ricardo Wurmus, Simon Tournier, Tobias Geerinckx-Rice
From: Ludovic Courtès <ludovic.courtes@inria.fr>
This also fixes <https://issues.guix.gnu.org/63726>.
* 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 <zimon.toutoune@gmail.com>
---
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 <konrad.hinsen@fastmail.net>
-;;; Copyright © 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019, 2020, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; 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
--
2.41.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files.
2023-08-17 10:17 ` [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
@ 2023-08-17 11:20 ` Simon Tournier
2023-08-17 17:10 ` bug#65229: [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes Ludovic Courtès
0 siblings, 1 reply; 12+ messages in thread
From: Simon Tournier @ 2023-08-17 11:20 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Ludovic Courtès, 65229
Hi,
On Thu, 17 Aug 2023 at 12:17, Ludovic Courtès <ludo@gnu.org> wrote:
> • Document the <(echo %default-channels) trick.
LGTM!
Well, it appears to me weird to document with this patch this track
and then introduce the implementation in the next commit. Anyway,
it's nitpicking. :-)
However, as I mentioned, I still find confusing the wording "main
branch" and I think "main branch of Guix (currently named
@code{master))" fixes the confusion.
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65229: [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes
2023-08-17 11:20 ` Simon Tournier
@ 2023-08-17 17:10 ` Ludovic Courtès
0 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2023-08-17 17:10 UTC (permalink / raw)
To: Simon Tournier; +Cc: 65229-done
Simon Tournier <zimon.toutoune@gmail.com> skribis:
> On Thu, 17 Aug 2023 at 12:17, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> • Document the <(echo %default-channels) trick.
>
> LGTM!
Pushed as 9c8098424b5be3abf21144c74162ec39c0c2e799, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-08-17 17:11 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 15:31 [bug#65229] [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes Ludovic Courtès
2023-08-11 15:34 ` [bug#65229] [PATCH 1/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
2023-08-16 12:59 ` Simon Tournier
2023-08-16 13:43 ` Simon Tournier
2023-08-17 8:56 ` Ludovic Courtès
2023-08-17 9:59 ` Simon Tournier
2023-08-17 10:17 ` [bug#65229] [PATCH v2 1/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
2023-08-17 10:17 ` [bug#65229] [PATCH v2 2/2] pull, time-machine: Add '-q' to ignore channel files Ludovic Courtès
2023-08-17 11:20 ` Simon Tournier
2023-08-17 17:10 ` bug#65229: [PATCH 0/2] Add '-q' for 'pull' and 'time-machine'; support loading from pipes Ludovic Courtès
2023-08-11 15:34 ` [bug#65229] [PATCH 2/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe Ludovic Courtès
2023-08-16 13:32 ` Simon Tournier
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).