aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-03-22 23:40:04 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-03-24 21:33:33 +0100
commite5f7029ba49a486c1b0c8011be79b8b41be20935 (patch)
tree1710bffa8625f0ab714d845922a845db6bd331a6 /src/nix
parent98658ae9d25e5e715f9349fbbb79d0ba31bb810c (diff)
nix store make-content-addressed: Support --from / --to
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/make-content-addressed.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nix/make-content-addressed.cc b/src/nix/make-content-addressed.cc
index dc0447cb8..34860c38f 100644
--- a/src/nix/make-content-addressed.cc
+++ b/src/nix/make-content-addressed.cc
@@ -6,7 +6,7 @@
using namespace nix;
-struct CmdMakeContentAddressed : StorePathsCommand, MixJSON
+struct CmdMakeContentAddressed : virtual CopyCommand, virtual StorePathsCommand, MixJSON
{
CmdMakeContentAddressed()
{
@@ -25,9 +25,11 @@ struct CmdMakeContentAddressed : StorePathsCommand, MixJSON
;
}
- void run(ref<Store> store, StorePaths && storePaths) override
+ void run(ref<Store> srcStore, StorePaths && storePaths) override
{
- auto remappings = makeContentAddressed(*store, *store,
+ auto dstStore = dstUri.empty() ? openStore() : openStore(dstUri);
+
+ auto remappings = makeContentAddressed(*srcStore, *dstStore,
StorePathSet(storePaths.begin(), storePaths.end()));
if (json) {
@@ -36,15 +38,15 @@ struct CmdMakeContentAddressed : StorePathsCommand, MixJSON
for (auto & path : storePaths) {
auto i = remappings.find(path);
assert(i != remappings.end());
- jsonRewrites.attr(store->printStorePath(path), store->printStorePath(i->second));
+ jsonRewrites.attr(srcStore->printStorePath(path), srcStore->printStorePath(i->second));
}
} else {
for (auto & path : storePaths) {
auto i = remappings.find(path);
assert(i != remappings.end());
notice("rewrote '%s' to '%s'",
- store->printStorePath(path),
- store->printStorePath(i->second));
+ srcStore->printStorePath(path),
+ srcStore->printStorePath(i->second));
}
}
}