about summary refs log tree commit diff
path: root/src/nix/copy.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-03-16T13·25+0100
committerEelco Dolstra <edolstra@gmail.com>2017-03-16T13·25+0100
commit558eda01154d47b3c88983576eedb582185b2201 (patch)
tree7771c3d52fe63335115c6436ad8c6f007c8e0e55 /src/nix/copy.cc
parent287084d688c3316d5840a9a7b5b2dff29b3dda94 (diff)
nix copy: Make -r option use the "from" store
Previously, we tried to compute the closure in the local store, which
obviously doesn't work.
Diffstat (limited to 'src/nix/copy.cc')
-rw-r--r--src/nix/copy.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nix/copy.cc b/src/nix/copy.cc
index 083dc3506863..b2165cb8f85c 100644
--- a/src/nix/copy.cc
+++ b/src/nix/copy.cc
@@ -38,13 +38,17 @@ struct CmdCopy : StorePathsCommand
         };
     }
 
-    void run(ref<Store> store, Paths storePaths) override
+    ref<Store> createStore() override
+    {
+        return srcUri.empty() ? StoreCommand::createStore() : openStore(srcUri);
+    }
+
+    void run(ref<Store> srcStore, Paths storePaths) override
     {
         if (srcUri.empty() && dstUri.empty())
             throw UsageError("you must pass ‘--from’ and/or ‘--to’");
 
-        ref<Store> srcStore = srcUri.empty() ? store : openStore(srcUri);
-        ref<Store> dstStore = dstUri.empty() ? store : openStore(dstUri);
+        ref<Store> dstStore = dstUri.empty() ? openStore() : openStore(dstUri);
 
         copyPaths(srcStore, dstStore, PathSet(storePaths.begin(), storePaths.end()));
     }