mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-09-21 17:08:04 +03:00
545c2d0d8c
The advantage is that the resulting closure doesn't need to be signed, so you don't need to configure any binary cache keys on the client.
54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
#include "command.hh"
|
|
#include "store-api.hh"
|
|
#include "make-content-addressed.hh"
|
|
#include "common-args.hh"
|
|
#include "json.hh"
|
|
|
|
using namespace nix;
|
|
|
|
struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
|
|
{
|
|
CmdMakeContentAddressable()
|
|
{
|
|
realiseMode = Realise::Outputs;
|
|
}
|
|
|
|
std::string description() override
|
|
{
|
|
return "rewrite a path or closure to content-addressed form";
|
|
}
|
|
|
|
std::string doc() override
|
|
{
|
|
return
|
|
#include "make-content-addressable.md"
|
|
;
|
|
}
|
|
|
|
void run(ref<Store> store, StorePaths && storePaths) override
|
|
{
|
|
auto remappings = makeContentAddressed(*store, *store,
|
|
StorePathSet(storePaths.begin(), storePaths.end()));
|
|
|
|
if (json) {
|
|
JSONObject jsonRoot(std::cout);
|
|
JSONObject jsonRewrites(jsonRoot.object("rewrites"));
|
|
for (auto & path : storePaths) {
|
|
auto i = remappings.find(path);
|
|
assert(i != remappings.end());
|
|
jsonRewrites.attr(store->printStorePath(path), store->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));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
static auto rCmdMakeContentAddressable = registerCommand2<CmdMakeContentAddressable>({"store", "make-content-addressable"});
|