mirror of
https://github.com/NixOS/nix
synced 2025-07-04 23:51:47 +02:00
Shuffle ValidPathInfo
JSON rendering
`Store::pathInfoToJSON` was a rather baroque functions, being full of parameters to support both parsed derivations and `nix path-info`. The common core of each, a simple `dValidPathInfo::toJSON` function, is factored out, but the rest of the logic is just duplicated and then specialized to its use-case (at which point it is no longer that duplicated). This keeps the human oriented CLI logic (which is currently unstable) and the core domain logic (export reference graphs with structured attrs, which is stable), separate, which I think is better.
This commit is contained in:
parent
0b0d1b5214
commit
937e02e7b9
15 changed files with 499 additions and 119 deletions
|
@ -125,6 +125,18 @@ struct ValidPathInfo : UnkeyedValidPathInfo {
|
|||
|
||||
Strings shortRefs() const;
|
||||
|
||||
/**
|
||||
* @param includeImpureInfo If true, variable elements such as the
|
||||
* registration time are included.
|
||||
*/
|
||||
virtual nlohmann::json toJSON(
|
||||
const Store & store,
|
||||
bool includeImpureInfo,
|
||||
HashFormat hashFormat) const;
|
||||
static ValidPathInfo fromJSON(
|
||||
const Store & store,
|
||||
const nlohmann::json & json);
|
||||
|
||||
ValidPathInfo(const ValidPathInfo & other) = default;
|
||||
|
||||
ValidPathInfo(StorePath && path, UnkeyedValidPathInfo info) : UnkeyedValidPathInfo(info), path(std::move(path)) { };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue