Skip to content

Commit 4b75eda

Browse files
committed
Restore NAR hash assertion
1 parent b813a76 commit 4b75eda

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libflake/flake/flake.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static std::tuple<ref<SourceAccessor>, FlakeRef, FlakeRef> fetchOrSubstituteTree
8585
static StorePath copyInputToStore(
8686
EvalState & state,
8787
fetchers::Input & input,
88+
const fetchers::Input & originalInput,
8889
ref<SourceAccessor> accessor)
8990
{
9091
auto storePath = fetchToStore(*state.store, accessor, FetchMode::Copy, input.getName());
@@ -94,9 +95,7 @@ static StorePath copyInputToStore(
9495
auto narHash = state.store->queryPathInfo(storePath)->narHash;
9596
input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
9697

97-
#if 0
98-
assert(!originalRef.input.getNarHash() || fetched->storePath == originalRef.input.computeStorePath(*state.store));
99-
#endif
98+
assert(!originalInput.getNarHash() || storePath == originalInput.computeStorePath(*state.store));
10099

101100
return storePath;
102101
}
@@ -421,7 +420,7 @@ static Flake getFlake(
421420
}
422421

423422
// Copy the tree to the store.
424-
auto storePath = copyInputToStore(state, lockedRef.input, accessor);
423+
auto storePath = copyInputToStore(state, lockedRef.input, originalRef.input, accessor);
425424

426425
// Re-parse flake.nix from the store.
427426
return readFlake(state, originalRef, resolvedRef, lockedRef, state.rootPath(state.store->toRealPath(storePath)), lockRootAttrPath);
@@ -784,7 +783,7 @@ LockedFlake lockFlake(
784783
state, *input.ref, useRegistries, flakeCache);
785784

786785
// FIXME: allow input to be lazy.
787-
auto storePath = copyInputToStore(state, lockedRef.input, accessor);
786+
auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor);
788787

789788
return {state.rootPath(state.store->toRealPath(storePath)), lockedRef};
790789
}

0 commit comments

Comments
 (0)