1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

Restore NAR hash assertion

This commit is contained in:
Eelco Dolstra 2025-02-10 17:13:17 +01:00
parent b813a764e0
commit 4b75edacd7

View file

@ -85,6 +85,7 @@ static std::tuple<ref<SourceAccessor>, FlakeRef, FlakeRef> fetchOrSubstituteTree
static StorePath copyInputToStore( static StorePath copyInputToStore(
EvalState & state, EvalState & state,
fetchers::Input & input, fetchers::Input & input,
const fetchers::Input & originalInput,
ref<SourceAccessor> accessor) ref<SourceAccessor> accessor)
{ {
auto storePath = fetchToStore(*state.store, accessor, FetchMode::Copy, input.getName()); auto storePath = fetchToStore(*state.store, accessor, FetchMode::Copy, input.getName());
@ -94,9 +95,7 @@ static StorePath copyInputToStore(
auto narHash = state.store->queryPathInfo(storePath)->narHash; auto narHash = state.store->queryPathInfo(storePath)->narHash;
input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true)); input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
#if 0 assert(!originalInput.getNarHash() || storePath == originalInput.computeStorePath(*state.store));
assert(!originalRef.input.getNarHash() || fetched->storePath == originalRef.input.computeStorePath(*state.store));
#endif
return storePath; return storePath;
} }
@ -421,7 +420,7 @@ static Flake getFlake(
} }
// Copy the tree to the store. // Copy the tree to the store.
auto storePath = copyInputToStore(state, lockedRef.input, accessor); auto storePath = copyInputToStore(state, lockedRef.input, originalRef.input, accessor);
// Re-parse flake.nix from the store. // Re-parse flake.nix from the store.
return readFlake(state, originalRef, resolvedRef, lockedRef, state.rootPath(state.store->toRealPath(storePath)), lockRootAttrPath); return readFlake(state, originalRef, resolvedRef, lockedRef, state.rootPath(state.store->toRealPath(storePath)), lockRootAttrPath);
@ -784,7 +783,7 @@ LockedFlake lockFlake(
state, *input.ref, useRegistries, flakeCache); state, *input.ref, useRegistries, flakeCache);
// FIXME: allow input to be lazy. // FIXME: allow input to be lazy.
auto storePath = copyInputToStore(state, lockedRef.input, accessor); auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor);
return {state.rootPath(state.store->toRealPath(storePath)), lockedRef}; return {state.rootPath(state.store->toRealPath(storePath)), lockedRef};
} }