aboutsummaryrefslogtreecommitdiff
path: root/src/nix/build.cc
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2022-11-25 08:14:32 -0500
committerGitHub <noreply@github.com>2022-11-25 08:14:32 -0500
commit26534f141cb52adf0135e86c71628cdef844a57a (patch)
treedff8140578d26993973cb8baf334948664b36660 /src/nix/build.cc
parent13f2a6f38db44385ae1c7d3d01170149de328abb (diff)
parentbc9692a6b701fffe25d2e3b1d16f00edd596930f (diff)
Merge branch 'master' into indexed-store-path-outputs
Diffstat (limited to 'src/nix/build.cc')
-rw-r--r--src/nix/build.cc38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc
index 9c648d28e..85b1efc33 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -10,6 +10,33 @@
using namespace nix;
+nlohmann::json derivedPathsToJSON(const DerivedPaths & paths, ref<Store> store)
+{
+ auto res = nlohmann::json::array();
+ for (auto & t : paths) {
+ std::visit([&res, store](const auto & t) {
+ res.push_back(t.toJSON(store));
+ }, t.raw());
+ }
+ return res;
+}
+
+nlohmann::json builtPathsWithResultToJSON(const std::vector<BuiltPathWithResult> & buildables, ref<Store> store)
+{
+ auto res = nlohmann::json::array();
+ for (auto & b : buildables) {
+ std::visit([&](const auto & t) {
+ auto j = t.toJSON(store);
+ if (b.result) {
+ j["startTime"] = b.result->startTime;
+ j["stopTime"] = b.result->stopTime;
+ }
+ res.push_back(j);
+ }, b.path.raw());
+ }
+ return res;
+}
+
struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
{
Path outLink = "result";
@@ -78,7 +105,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
Realise::Outputs,
installables, buildMode);
- if (json) logger->cout("%s", derivedPathsWithHintsToJSON(buildables, store).dump());
+ if (json) logger->cout("%s", builtPathsWithResultToJSON(buildables, store).dump());
if (outLink != "")
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
@@ -98,7 +125,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
store2->addPermRoot(output.second, absPath(symlink));
}
},
- }, buildable.raw());
+ }, buildable.path.raw());
}
if (printOutputPaths) {
@@ -113,11 +140,14 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
std::cout << store->printStorePath(output.second) << std::endl;
}
},
- }, buildable.raw());
+ }, buildable.path.raw());
}
}
- updateProfile(buildables);
+ BuiltPaths buildables2;
+ for (auto & b : buildables)
+ buildables2.push_back(b.path);
+ updateProfile(buildables2);
}
};