diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2023-08-01 16:07:20 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2023-08-01 16:07:20 +0200 |
commit | d9e7758f4756c10592407b3fe99dc253ef56eac9 (patch) | |
tree | 960315c30ed9cbc7dd182c391aba64f212dba183 /tests | |
parent | dcdd5fed74445c526a361202a9e6c8459a38726b (diff) |
Don't require .tar/.zip extension for tarball flakerefs
Special-casing the file name is rather ugly, so we shouldn't do
that. So now any {file,http,https} URL is handled by
TarballInputScheme, except for non-flake inputs (i.e. inputs that have
the attribute `flake = false`).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fetchTree-file.sh | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/fetchTree-file.sh b/tests/fetchTree-file.sh index fe569cfb8..6395c133d 100644 --- a/tests/fetchTree-file.sh +++ b/tests/fetchTree-file.sh @@ -27,6 +27,7 @@ test_file_flake_input () { mkdir inputs echo foo > inputs/test_input_file + echo '{ outputs = { self }: { }; }' > inputs/flake.nix tar cfa test_input.tar.gz inputs cp test_input.tar.gz test_input_no_ext input_tarball_hash="$(nix hash path test_input.tar.gz)" @@ -50,6 +51,9 @@ test_file_flake_input () { url = "file+file://$PWD/test_input.tar.gz"; flake = false; }; + inputs.flake_no_ext = { + url = "file://$PWD/test_input_no_ext"; + }; outputs = { ... }: {}; } EOF @@ -58,7 +62,7 @@ EOF nix eval --file - <<EOF with (builtins.fromJSON (builtins.readFile ./flake.lock)); - # Url inputs whose extension doesn’t match a known archive format should + # Non-flake inputs whose extension doesn’t match a known archive format should # not be unpacked by default assert (nodes.no_ext_default_no_unpack.locked.type == "file"); assert (nodes.no_ext_default_no_unpack.locked.unpack or false == false); @@ -75,8 +79,16 @@ EOF # Explicitely passing the unpack parameter should enforce the desired behavior assert (nodes.no_ext_explicit_unpack.locked.narHash == nodes.tarball_default_unpack.locked.narHash); assert (nodes.tarball_explicit_no_unpack.locked.narHash == nodes.no_ext_default_no_unpack.locked.narHash); + + # Flake inputs should always be tarballs + assert (nodes.flake_no_ext.locked.type == "tarball"); + true EOF + + # Test tarball URLs on the command line. + [[ $(nix flake metadata --json file://$PWD/test_input_no_ext | jq -r .resolved.type) = tarball ]] + popd [[ -z "${NIX_DAEMON_PACKAGE-}" ]] && return 0 |