ui: 'load*' accepts /dev/fd/N files pointing to a pipe.

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.
This commit is contained in:
Ludovic Courtès 2023-08-11 17:20:06 +02:00 committed by Ludovic Courtès
parent 9896b37ac5
commit 3363ff1867
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 23 additions and 2 deletions

View file

@ -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