Check hash

This commit is contained in:
Eelco Dolstra 2019-06-04 20:34:44 +02:00
parent 45b5c606ac
commit 1c5067b9a7
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 6 additions and 2 deletions

View file

@ -409,8 +409,6 @@ static void emitSourceInfoAttrs(EvalState & state, const SourceInfo & sourceInfo
{ {
auto & path = sourceInfo.storePath; auto & path = sourceInfo.storePath;
assert(state.store->isValidPath(path)); assert(state.store->isValidPath(path));
// FIXME: turn into fetchGit etc.
// FIXME: check narHash.
mkString(*state.allocAttr(vAttrs, state.sOutPath), path, {path}); mkString(*state.allocAttr(vAttrs, state.sOutPath), path, {path});
if (sourceInfo.resolvedRef.rev) { if (sourceInfo.resolvedRef.rev) {
@ -436,6 +434,10 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
{ {
auto lazyFlake = (FlakeInput *) args[0]->attrs; auto lazyFlake = (FlakeInput *) args[0]->attrs;
auto flake = getFlake(state, lazyFlake->ref, false); auto flake = getFlake(state, lazyFlake->ref, false);
if (flake.sourceInfo.narHash != lazyFlake->narHash)
throw Error("the content hash of flake '%s' doesn't match the hash recorded in the referring lockfile", flake.sourceInfo.resolvedRef);
callFlake(state, flake, *lazyFlake, v); callFlake(state, flake, *lazyFlake, v);
} }

View file

@ -106,5 +106,7 @@ struct LockFile : FlakeInputs
void write(const Path & path) const; void write(const Path & path) const;
}; };
std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
} }