aboutsummaryrefslogtreecommitdiff
path: root/src/nix/make-content-addressed.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 10:56:22 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 10:56:22 -0500
commit989b8065b45e52a8df2a803b1a72e0d0a7c35536 (patch)
treeffd7d779cf35dc13396aef3b1871a7bc954af350 /src/nix/make-content-addressed.cc
parent08b8657978de0d56064aad9c3e925b64d91b28a2 (diff)
parente9fc1e4fdb0ab5adb6b163c3db361b86a4f5c69b (diff)
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/nix/make-content-addressed.cc')
-rw-r--r--src/nix/make-content-addressed.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nix/make-content-addressed.cc b/src/nix/make-content-addressed.cc
index 34860c38f..d86b90fc7 100644
--- a/src/nix/make-content-addressed.cc
+++ b/src/nix/make-content-addressed.cc
@@ -2,10 +2,13 @@
#include "store-api.hh"
#include "make-content-addressed.hh"
#include "common-args.hh"
-#include "json.hh"
+
+#include <nlohmann/json.hpp>
using namespace nix;
+using nlohmann::json;
+
struct CmdMakeContentAddressed : virtual CopyCommand, virtual StorePathsCommand, MixJSON
{
CmdMakeContentAddressed()
@@ -25,6 +28,7 @@ struct CmdMakeContentAddressed : virtual CopyCommand, virtual StorePathsCommand,
;
}
+ using StorePathsCommand::run;
void run(ref<Store> srcStore, StorePaths && storePaths) override
{
auto dstStore = dstUri.empty() ? openStore() : openStore(dstUri);
@@ -33,13 +37,15 @@ struct CmdMakeContentAddressed : virtual CopyCommand, virtual StorePathsCommand,
StorePathSet(storePaths.begin(), storePaths.end()));
if (json) {
- JSONObject jsonRoot(std::cout);
- JSONObject jsonRewrites(jsonRoot.object("rewrites"));
+ auto jsonRewrites = json::object();
for (auto & path : storePaths) {
auto i = remappings.find(path);
assert(i != remappings.end());
- jsonRewrites.attr(srcStore->printStorePath(path), srcStore->printStorePath(i->second));
+ jsonRewrites[srcStore->printStorePath(path)] = srcStore->printStorePath(i->second);
}
+ auto json = json::object();
+ json["rewrites"] = jsonRewrites;
+ std::cout << json.dump();
} else {
for (auto & path : storePaths) {
auto i = remappings.find(path);