diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-07-16 09:37:33 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-07-22 09:59:51 +0200 |
commit | e9848beca704d27a13e28b4403251725bd485bb2 (patch) | |
tree | 560b21607427e1a4c8af5a06f5391f7dfb7bf15d /src/libstore | |
parent | 2ff3035cf4d5167d180878d69cb47b31890a24c4 (diff) |
nix-build: Copy drv closure between eval store and build store
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/store-api.cc | 27 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 40a406468..d040560ca 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -9,6 +9,7 @@ #include "url.hh" #include "archive.hh" #include "callback.hh" +#include "remote-store.hh" #include <regex> @@ -881,6 +882,16 @@ std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStor for (auto & path : storePaths) pathsMap.insert_or_assign(path, path); + // FIXME: Temporary hack to copy closures in a single round-trip. + if (dynamic_cast<RemoteStore *>(&*dstStore)) { + if (!missing.empty()) { + auto source = sinkToSource([&](Sink & sink) { + srcStore->exportPaths(missing, sink); + }); + dstStore->importPaths(*source, NoCheckSigs); + } + return pathsMap; + } Activity act(*logger, lvlInfo, actCopyPaths, fmt("copying %d paths", missing.size())); @@ -958,6 +969,22 @@ std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStor return pathsMap; } +void copyClosure( + ref<Store> srcStore, + ref<Store> dstStore, + const RealisedPath::Set & paths, + RepairFlag repair, + CheckSigsFlag checkSigs, + SubstituteFlag substitute) +{ + if (srcStore == dstStore) return; + + RealisedPath::Set closure; + RealisedPath::closure(*srcStore, paths, closure); + + copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute); +} + std::optional<ValidPathInfo> decodeValidPathInfo(const Store & store, std::istream & str, std::optional<HashResult> hashGiven) { std::string path; diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 356ae615c..c39d9f894 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -773,6 +773,12 @@ std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStor CheckSigsFlag checkSigs = CheckSigs, SubstituteFlag substitute = NoSubstitute); +/* Copy the closure of `paths` from `srcStore` to `dstStore`. */ +void copyClosure(ref<Store> srcStore, ref<Store> dstStore, + const RealisedPath::Set & paths, + RepairFlag repair = NoRepair, + CheckSigsFlag checkSigs = CheckSigs, + SubstituteFlag substitute = NoSubstitute); /* Remove the temporary roots file for this process. Any temporary root becomes garbage after this point unless it has been registered |