aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derivations.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-03-30 11:06:52 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-04-07 08:34:58 -0400
commitb200784cec056da53378eb043cae4fad188e4e6f (patch)
tree1e9dcaf438a6b7f7348d811b9ec90a47f7befc14 /src/libstore/derivations.cc
parentfe9cbe838c3d59e2768b92d8cab0e5a2674f5bfb (diff)
Include the name in the JSON for derivations
This is non-breaking change in the to-JSON direction. This *is* a breaking change in the from-JSON direction, but we don't care, as that is brand new in this PR. `nix show-derivation --help` currently has the sole public documentation of this format, it is updated accordingly.
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r--src/libstore/derivations.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index ea4abb352..9f74f1c30 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -988,6 +988,8 @@ nlohmann::json Derivation::toJSON(const Store & store) const
{
nlohmann::json res = nlohmann::json::object();
+ res["name"] = name;
+
{
nlohmann::json & outputsObj = res["outputs"];
outputsObj = nlohmann::json::object();
@@ -1020,17 +1022,19 @@ nlohmann::json Derivation::toJSON(const Store & store) const
Derivation Derivation::fromJSON(
- const Store & store, std::string_view drvName,
+ const Store & store,
const nlohmann::json & json)
{
Derivation res;
+ res.name = json["name"];
+
{
auto & outputsObj = json["outputs"];
for (auto & [outputName, output] : outputsObj.items()) {
res.outputs.insert_or_assign(
outputName,
- DerivationOutput::fromJSON(store, drvName, outputName, output));
+ DerivationOutput::fromJSON(store, res.name, outputName, output));
}
}