aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-06-04 20:34:44 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-06-04 20:35:35 +0200
commit1c5067b9a7e1f561bf9e9e84642c495a50ca44a7 (patch)
treee5026a18318aeb31291bb9d28af8a623dec334ad /src
parent45b5c606ac44550de14562df4fa99773a81a1015 (diff)
Check hash
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/primops/flake.cc6
-rw-r--r--src/libexpr/primops/lockfile.hh2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc
index 6919bc66b..52d8df69e 100644
--- a/src/libexpr/primops/flake.cc
+++ b/src/libexpr/primops/flake.cc
@@ -409,8 +409,6 @@ static void emitSourceInfoAttrs(EvalState & state, const SourceInfo & sourceInfo
{
auto & path = sourceInfo.storePath;
assert(state.store->isValidPath(path));
- // FIXME: turn into fetchGit etc.
- // FIXME: check narHash.
mkString(*state.allocAttr(vAttrs, state.sOutPath), path, {path});
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 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);
}
diff --git a/src/libexpr/primops/lockfile.hh b/src/libexpr/primops/lockfile.hh
index f2e598528..b76124190 100644
--- a/src/libexpr/primops/lockfile.hh
+++ b/src/libexpr/primops/lockfile.hh
@@ -106,5 +106,7 @@ struct LockFile : FlakeInputs
void write(const Path & path) const;
};
+std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
+
}