aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/installables.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-06-29 21:17:48 +0200
committerEelco Dolstra <edolstra@gmail.com>2021-07-22 09:59:51 +0200
commit3d9de41a5b86520ff0c994dc7ac1023d2a441083 (patch)
treecdeb97e5054a32318ca8640f9effbf180ba1a40f /src/libcmd/installables.cc
parentbef40c29491ba9b31c85b9b89a5342979344f583 (diff)
Hacky fast closure copying mechanism
Diffstat (limited to 'src/libcmd/installables.cc')
-rw-r--r--src/libcmd/installables.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 66ec63da2..ca4d509c2 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -12,6 +12,7 @@
#include "eval-cache.hh"
#include "url.hh"
#include "registry.hh"
+#include "remote-store.hh"
#include <regex>
#include <queue>
@@ -378,6 +379,7 @@ DerivedPaths InstallableValue::toDerivedPaths()
DerivedPaths res;
std::map<StorePath, std::set<std::string>> drvsToOutputs;
+ RealisedPath::Set drvsToCopy;
// Group by derivation, helps with .all in particular
for (auto & drv : toDerivations()) {
@@ -385,11 +387,38 @@ DerivedPaths InstallableValue::toDerivedPaths()
if (outputName == "")
throw Error("derivation '%s' lacks an 'outputName' attribute", state->store->printStorePath(drv.drvPath));
drvsToOutputs[drv.drvPath].insert(outputName);
+ drvsToCopy.insert(drv.drvPath);
}
for (auto & i : drvsToOutputs)
res.push_back(DerivedPath::Built { i.first, i.second });
+ // FIXME: Temporary hack
+ if (state->store != state->buildStore) {
+ RealisedPath::Set closure;
+ RealisedPath::closure(*state->store, drvsToCopy, closure);
+
+ if (dynamic_cast<RemoteStore *>(&*state->buildStore)) {
+ StorePathSet closure2;
+ for (auto & p : closure)
+ closure2.insert(p.path());
+
+ auto valid = state->buildStore->queryValidPaths(closure2);
+ StorePathSet missing;
+ for (auto & p : closure2)
+ if (!valid.count(p)) missing.insert(p);
+
+ if (!missing.empty()) {
+ auto source = sinkToSource([&](Sink & sink) {
+ state->store->exportPaths(missing, sink);
+ });
+ state->buildStore->importPaths(*source, NoCheckSigs);
+ }
+
+ } else
+ copyPaths(state->store, state->buildStore, closure);
+ }
+
return res;
}