mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
nix flake info --json: List the "provides"
It also lists the contents of "checks" and "packages". For example: $ nix flake info --json | jq { "branch": "HEAD", "description": "The purely functional package manager", "epoch": 2019, "id": "nix", "lastModified": 1559161142, "path": "/nix/store/2w2qla8735dbxah8gai8r1nsbf5x4f5d-source", "provides": { "checks": { "binaryTarball": {}, "nix-copy-closure": {}, "perlBindings": {}, "remoteBuilds": {}, "setuid": {} }, "defaultPackage": {}, "devShell": {}, "hydraJobs": {}, "packages": { "nix": {}, "nix-perl-bindings": {} } }, "revCount": 6955, "revision": "8cb24e04e8b6cc60e2504733afe78e0eadafcd98", "uri": "/home/eelco/Dev/nix" } Fixes #2820.
This commit is contained in:
parent
3488fa7c6c
commit
49436bdbb7
1 changed files with 42 additions and 16 deletions
|
@ -199,6 +199,19 @@ struct CmdFlakeUpdate : FlakeCommand
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void enumerateProvides(EvalState & state, Value & vFlake,
|
||||||
|
std::function<void(const std::string & name, Value & vProvide)> callback)
|
||||||
|
{
|
||||||
|
state.forceAttrs(vFlake);
|
||||||
|
|
||||||
|
auto vProvides = (*vFlake.attrs->get(state.symbols.create("provides")))->value;
|
||||||
|
|
||||||
|
state.forceAttrs(*vProvides);
|
||||||
|
|
||||||
|
for (auto & attr : *vProvides->attrs)
|
||||||
|
callback(attr.name, *attr.value);
|
||||||
|
}
|
||||||
|
|
||||||
struct CmdFlakeInfo : FlakeCommand, MixJSON
|
struct CmdFlakeInfo : FlakeCommand, MixJSON
|
||||||
{
|
{
|
||||||
std::string name() override
|
std::string name() override
|
||||||
|
@ -215,26 +228,39 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
|
||||||
{
|
{
|
||||||
auto flake = getFlake();
|
auto flake = getFlake();
|
||||||
stopProgressBar();
|
stopProgressBar();
|
||||||
if (json)
|
|
||||||
std::cout << flakeToJson(flake).dump() << std::endl;
|
if (json) {
|
||||||
else
|
auto json = flakeToJson(flake);
|
||||||
|
|
||||||
|
auto state = getEvalState();
|
||||||
|
|
||||||
|
auto vFlake = state->allocValue();
|
||||||
|
flake::callFlake(*state, flake, *vFlake);
|
||||||
|
|
||||||
|
auto provides = nlohmann::json::object();
|
||||||
|
|
||||||
|
enumerateProvides(*state,
|
||||||
|
*vFlake,
|
||||||
|
[&](const std::string & name, Value & vProvide) {
|
||||||
|
auto provide = nlohmann::json::object();
|
||||||
|
|
||||||
|
if (name == "checks" || name == "packages") {
|
||||||
|
state->forceAttrs(vProvide);
|
||||||
|
for (auto & aCheck : *vProvide.attrs)
|
||||||
|
provide[aCheck.name] = nlohmann::json::object();
|
||||||
|
}
|
||||||
|
|
||||||
|
provides[name] = provide;
|
||||||
|
});
|
||||||
|
|
||||||
|
json["provides"] = std::move(provides);
|
||||||
|
|
||||||
|
std::cout << json.dump() << std::endl;
|
||||||
|
} else
|
||||||
printFlakeInfo(flake);
|
printFlakeInfo(flake);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void enumerateProvides(EvalState & state, Value & vFlake,
|
|
||||||
std::function<void(const std::string & name, Value & vProvide)> callback)
|
|
||||||
{
|
|
||||||
state.forceAttrs(vFlake);
|
|
||||||
|
|
||||||
auto vProvides = (*vFlake.attrs->get(state.symbols.create("provides")))->value;
|
|
||||||
|
|
||||||
state.forceAttrs(*vProvides);
|
|
||||||
|
|
||||||
for (auto & attr : *vProvides->attrs)
|
|
||||||
callback(attr.name, *attr.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CmdFlakeCheck : FlakeCommand, MixJSON
|
struct CmdFlakeCheck : FlakeCommand, MixJSON
|
||||||
{
|
{
|
||||||
bool build = true;
|
bool build = true;
|
||||||
|
|
Loading…
Reference in a new issue