-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Labels
Description
Hello, everyone—thank you all for your work!
Bug Description
The new behaviour for handling relative path
inputs in 2.26 causes nix flake archive
to error on a flake with such inputs.
Steps To Reproduce
Overview
-
Create a flake,
'1
, that has a sub-flake,'2
, as a relativepath
input. -
Run
nix flake archive
on'1
. This fails, reporting that it can't fetch'2
because it uses a relative path. -
My initial idea to work around this is to recover the old behaviour by explicitly specifying
narHash
for'2
—this seems to work. -
The following is a script that reproduces the error and showcases the work-around, followed by the output of running that script.
- For what it's worth, the behaviour of running the script seems consistent whether or not
'1
and'2
were already in the store.
- For what it's worth, the behaviour of running the script seems consistent whether or not
Script
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# [irrelevant] {{{1
exec <&- {_FD_1}>&1 {_FD_2}>&2 &>/dev/null
BASH_XTRACEFD=$_FD_2
set -o xtrace
_exit() {
exec {_FD_1}>&- {_FD_2}>&-
}
# Sets the working directory. {{{1
#
# - `$1` is used as the working directory if it's set; otherwise, a temporary
# directory is created, used as the working directory, and removed on exit from
# the shell.
{
if [ -v 1 ]; then
trap _exit EXIT
else
set -- "$(mktemp --directory)"
# shellcheck disable=SC2064
trap "pushd -0 && rm --recursive $1 || : && _exit" EXIT
fi
pushd "$1"
} # }}}
_archive() {
patch --strip=1
nix flake update x
nix flake archive "$(nix eval --raw --file flake.nix inputs.x.url)"
nix flake archive --json 1>&$_FD_1 2>&$_FD_2 || : archiving failed
}
_archive <<EOF
flake.nix | 4 ++++
x/flake.nix | 1 +
2 files changed, 5 insertions(+)
create mode 100644 flake.nix
create mode 100644 x/flake.nix
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..2e275c9
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,4 @@
+{
+ inputs.x.url = "path:./x/";
+ outputs = _: { };
+}
diff --git a/x/flake.nix b/x/flake.nix
new file mode 100644
index 0000000..1526486
--- /dev/null
+++ b/x/flake.nix
@@ -0,0 +1 @@
+{ outputs = _: { }; }
EOF
_archive <<EOF
flake.nix | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flake.nix b/flake.nix
index 2e275c9..f1b4653 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2 +2 @@
- inputs.x.url = "path:./x/";
+ inputs.x.url = "path:./x/?narHash=sha256-VO8KzRYOgpVx36ZrJgyhKBIqs/LCSt75RVaCYxQv9TY=";
EOF
Output
+ '[' -v 1 ']'
++ mktemp --directory
+ set -- /tmp/tmp.fesjqUKWYH
+ trap 'pushd -0 && rm --recursive /tmp/tmp.fesjqUKWYH || : && _exit' EXIT
+ pushd /tmp/tmp.fesjqUKWYH
+ _archive
+ patch --strip=1
+ nix flake update x
++ nix eval --raw --file flake.nix inputs.x.url
+ nix flake archive path:./x/
+ nix flake archive --json
error:
… while fetching the input 'path:./x/'
error: cannot fetch input 'path:./x/' because it uses a relative path
+ : archiving failed
+ _archive
+ patch --strip=1
+ nix flake update x
++ nix eval --raw --file flake.nix inputs.x.url
+ nix flake archive 'path:./x/?narHash=sha256-VO8KzRYOgpVx36ZrJgyhKBIqs/LCSt75RVaCYxQv9TY='
+ nix flake archive --json
{"inputs":{"x":{"inputs":{},"path":"/nix/store/9vym1f1kyygc8aj8h7fd5zhrk3532062-source"}},"path":"/nix/store/00jg3xpsfbdn572j4dmgkksw5p2cmgs1-source"}
+ pushd -0
+ rm --recursive /tmp/tmp.fesjqUKWYH
+ _exit
+ exec
Metadata
nix (Nix) 2.26.1
Additional Context
This is known to affect:
Checklist
- checked
latest Nix manualImprove support for relative path inputs #10089 - checked open bug issues and pull requests for possible duplicates
Add 👍 to issues you find important.
jasonminsookim, jraygauthier and refaelsh