about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 31fff0b493e8..77721a5a8d87 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -165,9 +165,15 @@ static void processBinding(EvalState & state, Expr e, Derivation & drv,
             if (isDerivation(srcPath))
                 throw Error(format("file names are not allowed to end in `%1%'")
                     % drvExtension);
-            Path dstPath(addToStore(srcPath));
-            printMsg(lvlChatty, format("copied source `%1%' -> `%2%'")
-                % srcPath % dstPath);
+            Path dstPath;
+            if (state.srcToStore[srcPath] != "")
+                dstPath = state.srcToStore[srcPath];
+            else {
+                dstPath = addToStore(srcPath);
+                state.srcToStore[srcPath] = dstPath;
+                printMsg(lvlChatty, format("copied source `%1%' -> `%2%'")
+                    % srcPath % dstPath);
+            }
             drv.inputSrcs.insert(dstPath);
             ss.push_back(dstPath);
         }