mirror of
https://github.com/NixOS/nix
synced 2025-07-07 18:31:49 +02:00
Fix emitting narHash in lock files when lazy trees are disabled
This commit is contained in:
parent
9bbe06be3a
commit
4ea5cb3832
3 changed files with 3 additions and 2 deletions
|
@ -77,7 +77,7 @@ StorePath EvalState::mountInput(
|
||||||
|
|
||||||
storeFS->mount(CanonPath(store->printStorePath(storePath)), accessor);
|
storeFS->mount(CanonPath(store->printStorePath(storePath)), accessor);
|
||||||
|
|
||||||
if (requireLockable && !input.isLocked() && !input.getNarHash()) {
|
if (requireLockable && (!settings.lazyTrees || !input.isLocked()) && !input.getNarHash()) {
|
||||||
auto narHash = accessor->hashPath(CanonPath::root);
|
auto narHash = accessor->hashPath(CanonPath::root);
|
||||||
input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ path11=$(nix eval --impure --raw --expr "(builtins.fetchGit ./.).outPath")
|
||||||
empty="$TEST_ROOT/empty"
|
empty="$TEST_ROOT/empty"
|
||||||
git init "$empty"
|
git init "$empty"
|
||||||
|
|
||||||
emptyAttrs='{ lastModified = 0; lastModifiedDate = "19700101000000"; rev = "0000000000000000000000000000000000000000"; revCount = 0; shortRev = "0000000"; submodules = false; }'
|
emptyAttrs='{ lastModified = 0; lastModifiedDate = "19700101000000"; narHash = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="; rev = "0000000000000000000000000000000000000000"; revCount = 0; shortRev = "0000000"; submodules = false; }'
|
||||||
|
|
||||||
[[ $(nix eval --impure --expr "builtins.removeAttrs (builtins.fetchGit $empty) [\"outPath\"]") = $emptyAttrs ]]
|
[[ $(nix eval --impure --expr "builtins.removeAttrs (builtins.fetchGit $empty) [\"outPath\"]") = $emptyAttrs ]]
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,7 @@ expect 1 nix build -o "$TEST_ROOT/result" "$flake2Dir#bar" --no-update-lock-file
|
||||||
nix build -o "$TEST_ROOT/result" "$flake2Dir#bar" --commit-lock-file
|
nix build -o "$TEST_ROOT/result" "$flake2Dir#bar" --commit-lock-file
|
||||||
[[ -e "$flake2Dir/flake.lock" ]]
|
[[ -e "$flake2Dir/flake.lock" ]]
|
||||||
[[ -z $(git -C "$flake2Dir" diff main || echo failed) ]]
|
[[ -z $(git -C "$flake2Dir" diff main || echo failed) ]]
|
||||||
|
[[ -n $(jq .nodes.flake1.locked.narHash < "$flake2Dir/flake.lock") ]]
|
||||||
|
|
||||||
# Rerunning the build should not change the lockfile.
|
# Rerunning the build should not change the lockfile.
|
||||||
nix build -o "$TEST_ROOT/result" "$flake2Dir#bar"
|
nix build -o "$TEST_ROOT/result" "$flake2Dir#bar"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue