mirror of
https://github.com/NixOS/nix.git
synced 2025-12-23 01:11:07 +01:00
Bring nix derivation show in compliance with JSON guidelines
This matches what we just did for `nix path-info`, and I hope will allow us to avoiding any more breaking changes to this command for the foreseeable future.
This commit is contained in:
parent
8b955d80c2
commit
0f18076f3a
9 changed files with 34 additions and 11 deletions
|
|
@ -1489,8 +1489,6 @@ adl_serializer<DerivationOutput>::from_json(const json & _json, const Experiment
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned constexpr expectedJsonVersionDerivation = 4;
|
||||
|
||||
void adl_serializer<Derivation>::to_json(json & res, const Derivation & d)
|
||||
{
|
||||
res = nlohmann::json::object();
|
||||
|
|
|
|||
|
|
@ -586,6 +586,12 @@ void writeDerivation(Sink & out, const StoreDirConfig & store, const BasicDeriva
|
|||
*/
|
||||
std::string hashPlaceholder(const OutputNameView outputName);
|
||||
|
||||
/**
|
||||
* The expected JSON version for derivation serialization.
|
||||
* Used by `nix derivation show` and `nix derivation add`.
|
||||
*/
|
||||
constexpr unsigned expectedJsonVersionDerivation = 4;
|
||||
|
||||
} // namespace nix
|
||||
|
||||
JSON_IMPL_WITH_XP_FEATURES(nix::DerivationOutput)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,11 @@ struct CmdShowDerivation : InstallablesCommand, MixPrintJSON
|
|||
|
||||
jsonRoot[drvPath.to_string()] = store->readDerivation(drvPath);
|
||||
}
|
||||
printJSON(jsonRoot);
|
||||
printJSON(
|
||||
nlohmann::json{
|
||||
{"version", expectedJsonVersionDerivation},
|
||||
{"derivations", std::move(jsonRoot)},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue