diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2023-08-07 17:02:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-07 17:02:17 +0200 |
commit | eb1302670e49e5bcf9f01f1cfaeaa6e62c383290 (patch) | |
tree | 18f76c64d482e6a1facc2d46ac67e409f8430aeb /tests/fetchTree-file.sh | |
parent | 5df0f1755f36c2dbee29e5e434e1adc138601d5f (diff) | |
parent | d9e7758f4756c10592407b3fe99dc253ef56eac9 (diff) |
Merge pull request #8769 from edolstra/generalize-tarball-urls
Don't require .tar/.zip extension for tarball flakerefs
Diffstat (limited to 'tests/fetchTree-file.sh')
-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 |