aboutsummaryrefslogtreecommitdiff
path: root/src/nix/copy.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2021-05-17 08:45:08 +0200
committerregnat <rg@regnat.ovh>2021-05-17 08:45:08 +0200
commit21050846457f356346204dd52fb7a6d49f710688 (patch)
treeb431f5168d57bef20608b6e36e11e11cc9843b34 /src/nix/copy.cc
parentec613603ba324bf12f8f554d74fb1a02c6e9b472 (diff)
Enfore the use of properly built paths in libcmd
Replace `DerivedPathWithHints` by a new `BuiltPath` type that serves as a proof that the corresponding path has been built.
Diffstat (limited to 'src/nix/copy.cc')
-rw-r--r--src/nix/copy.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/nix/copy.cc b/src/nix/copy.cc
index f59f7c76b..674cce4b4 100644
--- a/src/nix/copy.cc
+++ b/src/nix/copy.cc
@@ -8,7 +8,7 @@
using namespace nix;
-struct CmdCopy : RealisedPathsCommand
+struct CmdCopy : BuiltPathsCommand
{
std::string srcUri, dstUri;
@@ -16,10 +16,10 @@ struct CmdCopy : RealisedPathsCommand
SubstituteFlag substitute = NoSubstitute;
- using RealisedPathsCommand::run;
+ using BuiltPathsCommand::run;
CmdCopy()
- : RealisedPathsCommand(true)
+ : BuiltPathsCommand(true)
{
addFlag({
.longName = "from",
@@ -75,16 +75,22 @@ struct CmdCopy : RealisedPathsCommand
if (srcUri.empty() && dstUri.empty())
throw UsageError("you must pass '--from' and/or '--to'");
- RealisedPathsCommand::run(store);
+ BuiltPathsCommand::run(store);
}
- void run(ref<Store> srcStore, std::vector<RealisedPath> paths) override
+ void run(ref<Store> srcStore, BuiltPaths paths) override
{
ref<Store> dstStore = dstUri.empty() ? openStore() : openStore(dstUri);
+ RealisedPath::Set stuffToCopy;
+
+ for (auto & builtPath : paths) {
+ auto theseRealisations = builtPath.toRealisedPaths(*srcStore);
+ stuffToCopy.insert(theseRealisations.begin(), theseRealisations.end());
+ }
+
copyPaths(
- srcStore, dstStore, RealisedPath::Set(paths.begin(), paths.end()),
- NoRepair, checkSigs, substitute);
+ srcStore, dstStore, stuffToCopy, NoRepair, checkSigs, substitute);
}
};