Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ci/gha/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ rec {
'';
repl-completion = pkgs.callPackage ../../../tests/repl-completion.nix { inherit (packages') nix; };

lazyTrees = nixComponents.nix-functional-tests.override {
pname = "nix-lazy-trees-tests";
lazyTrees = true;
};

/**
Checks for our packaging expressions.
This shouldn't build anything significant; just check that things
Expand Down
5 changes: 3 additions & 2 deletions src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4729,8 +4729,9 @@ static void prim_hashString(EvalState & state, const PosIdx pos, Value ** args,
state.error<EvalError>("unknown hash algorithm '%1%'", algo).atPos(pos).debugThrow();

NixStringContext context; // discarded
auto s =
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.hashString");
auto s = state.devirtualize(
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.hashString"),
context);

v.mkString(hashString(*ha, s).to_string(HashFormat::Base16, false), state.mem);
}
Expand Down
4 changes: 2 additions & 2 deletions src/nix/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ UnresolvedApp InstallableValue::toApp(EvalState & state)
},
[&](const NixStringContextElem::Opaque & o) -> DerivedPath {
return DerivedPath::Opaque{
.path = o.path,
.path = state.devirtualize(o.path),
};
},
[&](const NixStringContextElem::Path & p) -> DerivedPath {
Expand All @@ -102,7 +102,7 @@ UnresolvedApp InstallableValue::toApp(EvalState & state)

return UnresolvedApp{App{
.context = std::move(context2),
.program = program,
.program = state.devirtualize(program, context),
}};
}

Expand Down
14 changes: 14 additions & 0 deletions tests/functional/fetchGit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,17 @@ rm "$TEST_ROOT"/flake/flake.lock
nix eval "path:$TEST_ROOT/flake"#isModern
nix eval --nix-219-compat "path:$TEST_ROOT/flake"#isModern
[[ $(jq -r .nodes.eol.locked.narHash < "$TEST_ROOT"/flake/flake.lock) = "$newHash" ]]


# Test that builtins.hashString devirtualizes lazy paths (https://github.com/DeterminateSystems/determinate/issues/160).
hashStringRepo="$TEST_ROOT/hashString"
createGitRepo "$hashStringRepo"
echo hello > "$hashStringRepo"/hello
git -C "$hashStringRepo" add hello
git -C "$hashStringRepo" commit -m 'Initial'
hashStringRev=$(git -C "$hashStringRepo" rev-parse HEAD)

hash1=$(nix eval --lazy-trees --raw --expr "builtins.hashString \"sha256\" (toString ((builtins.fetchGit { url = file://$hashStringRepo; rev = \"$hashStringRev\"; })))")
hash2=$(nix eval --lazy-trees --raw --expr "builtins.hashString \"sha256\" (toString ((builtins.fetchGit { url = file://$hashStringRepo; rev = \"$hashStringRev\"; })))")

[[ "$hash1" = "$hash2" ]]
Loading