about summary refs log tree commit diff
path: root/src/nix-copy-closure
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-02-07T19·55+0100
committerEelco Dolstra <edolstra@gmail.com>2017-02-07T19·55+0100
commit4724903c78e80481fc63d627081fac6a98e4205d (patch)
tree23e4c0b13e52b7e8448a1824c4370b6d58757073 /src/nix-copy-closure
parent6f4682ad36c97355fbb7ba86a9ce265c22102055 (diff)
nix-copy-closure: Use computeFSClosure() and LegacySSHStore
Diffstat (limited to 'src/nix-copy-closure')
-rwxr-xr-xsrc/nix-copy-closure/nix-copy-closure.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/nix-copy-closure/nix-copy-closure.cc b/src/nix-copy-closure/nix-copy-closure.cc
index b7e997ca4b0c..4340443b5cc2 100755
--- a/src/nix-copy-closure/nix-copy-closure.cc
+++ b/src/nix-copy-closure/nix-copy-closure.cc
@@ -7,13 +7,15 @@ int main(int argc, char ** argv)
 {
     return handleExceptions(argv[0], [&]() {
         initNix();
+
         auto gzip = false;
         auto toMode = true;
         auto includeOutputs = false;
         auto dryRun = false;
         auto useSubstitutes = false;
-        auto sshHost = string{};
-        auto storePaths = PathSet{};
+        std::string sshHost;
+        PathSet storePaths;
+
         parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
             if (*arg == "--help")
                 showManPage("nix-copy-closure");
@@ -41,20 +43,17 @@ int main(int argc, char ** argv)
                 storePaths.insert(*arg);
             return true;
         });
+
         if (sshHost.empty())
             throw UsageError("no host name specified");
 
-        auto remoteUri = "ssh://" + sshHost + (gzip ? "?compress=true" : "");
+        auto remoteUri = "legacy-ssh://" + sshHost + (gzip ? "?compress=true" : "");
         auto to = toMode ? openStore(remoteUri) : openStore();
         auto from = toMode ? openStore() : openStore(remoteUri);
-        if (includeOutputs) {
-            auto newPaths = PathSet{};
-            for (const auto & p : storePaths) {
-                auto outputs = from->queryDerivationOutputs(p);
-                newPaths.insert(outputs.begin(), outputs.end());
-            }
-            storePaths.insert(newPaths.begin(), newPaths.end());
-        }
-        copyPaths(from, to, Paths(storePaths.begin(), storePaths.end()), useSubstitutes);
+
+        PathSet closure;
+        from->computeFSClosure(storePaths, closure, false, includeOutputs);
+
+        copyPaths(from, to, Paths(closure.begin(), closure.end()), useSubstitutes);
     });
 }