Check LockedInput::computeStorePath()

This commit is contained in:
Eelco Dolstra 2020-01-30 00:13:37 +01:00
parent b9fb372075
commit b9f93e7386
3 changed files with 8 additions and 3 deletions

View file

@ -584,6 +584,8 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
throw Error("the content hash of flake '%s' doesn't match the hash recorded in the referring lockfile",
lazyInput->lockedInput.ref);
assert(flake.sourceInfo->storePath == lazyInput->lockedInput.computeStorePath(*state.store));
callFlake(state, flake, lazyInput->lockedInput, v);
} else {
FlakeCache flakeCache;
@ -593,6 +595,8 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
throw Error("the content hash of repository '%s' doesn't match the hash recorded in the referring lockfile",
lazyInput->lockedInput.ref);
assert(sourceInfo.storePath == lazyInput->lockedInput.computeStorePath(*state.store));
state.mkAttrs(v, 8);
assert(state.store->isValidPath(sourceInfo.storePath));

View file

@ -25,9 +25,9 @@ nlohmann::json LockedInput::toJson() const
return json;
}
Path LockedInput::computeStorePath(Store & store) const
StorePath LockedInput::computeStorePath(Store & store) const
{
return store.printStorePath(store.makeFixedOutputPath(true, narHash, "source"));
return store.makeFixedOutputPath(true, narHash, "source");
}
LockedInputs::LockedInputs(const nlohmann::json & json)

View file

@ -6,6 +6,7 @@
namespace nix {
class Store;
struct StorePath;
}
namespace nix::flake {
@ -53,7 +54,7 @@ struct LockedInput : LockedInputs
nlohmann::json toJson() const;
Path computeStorePath(Store & store) const;
StorePath computeStorePath(Store & store) const;
};
/* An entire lock file. Note that this cannot be a FlakeInput for the