mirror of
https://github.com/NixOS/nix
synced 2025-06-29 02:11:15 +02:00
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.
This commit is contained in:
parent
fe9cbe838c
commit
b200784cec
4 changed files with 11 additions and 4 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue