about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/primops.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 9208f0b247a8..b85cdbadd88c 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -100,8 +100,14 @@ static Path copyAtom(EvalState & state, const Path & srcPath)
 
     Path drvPath = writeTerm(unparseStoreExpr(ne), "c");
 
+    /* !!! can we get rid of drvRoots? */
     state.drvRoots[drvPath] = ne.closure.roots;
 
+    /* Optimisation, but required in read-only mode! because in that
+       case we don't actually write store expressions, so we can't
+       read them later. */
+    state.drvHashes[drvPath] = hashDerivationModulo(state, ne);
+
     printMsg(lvlChatty, format("copied `%1%' -> closure `%2%'")
         % srcPath % drvPath);
     return drvPath;
@@ -326,6 +332,11 @@ static Expr primDerivation(EvalState & state, const ATermVector & _args)
     printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'")
         % drvName % drvPath);
 
+    /* Optimisation, but required in read-only mode! because in that
+       case we don't actually write store expressions, so we can't
+       read them later. */
+    state.drvHashes[drvPath] = hashDerivationModulo(state, ne);
+
     /* !!! assumes a single output */
     attrs.set("outPath", makeAttrRHS(makePath(toATerm(outPath)), makeNoPos()));
     attrs.set("drvPath", makeAttrRHS(makePath(toATerm(drvPath)), makeNoPos()));