source common.sh clearStore cd "$TEST_ROOT" echo foo > test_input test_input_hash="$(nix hash path test_input)" test_fetch_file () { nix eval --raw --impure --file - < 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)" input_directory_hash="$(nix hash path inputs)" cat < flake.nix { inputs.no_ext_default_no_unpack = { url = "file://$PWD/test_input_no_ext"; flake = false; }; inputs.no_ext_explicit_unpack = { url = "tarball+file://$PWD/test_input_no_ext"; flake = false; }; inputs.tarball_default_unpack = { url = "file://$PWD/test_input.tar.gz"; flake = false; }; inputs.tarball_explicit_no_unpack = { url = "file+file://$PWD/test_input.tar.gz"; flake = false; }; inputs.flake_no_ext = { url = "file://$PWD/test_input_no_ext"; }; outputs = { ... }: {}; } EOF nix flake update nix eval --file - < flake.nix { inputs.tarball = { url = "file://$PWD/test_input.tar.gz"; flake = false; }; outputs = { self, tarball }: { foo = builtins.readFile "\${tarball}/test_input_file"; }; } nix flake update clearStore "$NIX_DAEMON_PACKAGE/bin/nix" eval .#foo EOF } test_file_flake_input fetch_file_path=$(test_fetch_file) fetch_substitute_path=$(test_substitution) # Substituting with a narHash should give you the same path as fetching it # directly, which should give you the same path as throwing it in the store # with recursive ingestion mode. # Regression test for https://git.lix.systems/lix-project/lix/issues/750 [[ "$fetch_file_path" == "$fetch_substitute_path" ]] # n.b. these are done after the first one which directly fetches the file in # order to make sure that substitution is *not* at play in test_fetch_file flat_hash_path=$(nix store add-file --name source ./test_input) recursive_hash_path=$(nix store add-path --name source ./test_input) # Fetching the file should give you a recursive-hashed path [[ "$flat_hash_path" != "$recursive_hash_path" ]] [[ "$fetch_file_path" == "$recursive_hash_path" ]]