about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc3
-rw-r--r--src/libexpr/eval.hh4
-rw-r--r--src/libexpr/primops.cc6
3 files changed, 9 insertions, 4 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 9e5be908f089..2f9601ec550f 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -141,6 +141,7 @@ EvalState::EvalState()
     , baseEnv(allocEnv(128))
     , baseEnvDispl(0)
     , staticBaseEnv(false, 0)
+    , repair(false)
 {
     nrEnvs = nrValuesInEnvs = nrValues = nrListElems = 0;
     nrAttrsets = nrOpUpdates = nrOpUpdateValuesCopied = 0;
@@ -1093,7 +1094,7 @@ string EvalState::coerceToString(Value & v, PathSet & context,
         else {
             dstPath = settings.readOnlyMode
                 ? computeStorePathForPath(path).first
-                : store->addToStore(path);
+                : store->addToStore(path, true, htSHA256, defaultPathFilter, repair);
             srcToStore[path] = dstPath;
             printMsg(lvlChatty, format("copied source `%1%' -> `%2%'")
                 % path % dstPath);
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index a1f26a0566d1..a3c55a38860f 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -95,6 +95,10 @@ public:
     const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName,
         sSystem, sOverrides;
 
+    /* If set, force copying files to the Nix store even if they
+       already exist there. */
+    bool repair;
+
 private:
     SrcToStore srcToStore; 
 
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index bbe89c5f55be..509297003f6e 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -487,7 +487,7 @@ static void prim_derivationStrict(EvalState & state, Value * * args, Value & v)
     }
 
     /* Write the resulting term into the Nix store directory. */
-    Path drvPath = writeDerivation(*store, drv, drvName);
+    Path drvPath = writeDerivation(*store, drv, drvName, state.repair);
 
     printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'")
         % drvName % drvPath);
@@ -625,7 +625,7 @@ static void prim_toFile(EvalState & state, Value * * args, Value & v)
     
     Path storePath = settings.readOnlyMode
         ? computeStorePathForText(name, contents, refs)
-        : store->addTextToStore(name, contents, refs);
+        : store->addTextToStore(name, contents, refs, state.repair);
 
     /* Note: we don't need to add `context' to the context of the
        result, since `storePath' itself has references to the paths
@@ -689,7 +689,7 @@ static void prim_filterSource(EvalState & state, Value * * args, Value & v)
 
     Path dstPath = settings.readOnlyMode
         ? computeStorePathForPath(path, true, htSHA256, filter).first
-        : store->addToStore(path, true, htSHA256, filter);
+        : store->addToStore(path, true, htSHA256, filter, state.repair);
 
     mkString(v, dstPath, singleton<PathSet>(dstPath));
 }