nix flake info --json: Don't evaluate

This makes its behaviour consistent with the non-json
variant. Querying the outputs should be done by another command
(e.g. 'nix search')
This commit is contained in:
Eelco Dolstra 2020-04-06 14:39:47 +02:00
parent 2f494531b7
commit ce3173edc1
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -153,40 +153,15 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
void run(nix::ref<nix::Store> store) override
{
if (json) {
auto state = getEvalState();
auto flake = lockFlake();
auto json = flakeToJson(*store, flake.flake);
auto vFlake = state->allocValue();
flake::callFlake(*state, flake, *vFlake);
auto outputs = nlohmann::json::object();
enumerateOutputs(*state,
*vFlake,
[&](const std::string & name, Value & vProvide, const Pos & pos) {
auto provide = nlohmann::json::object();
if (name == "checks" || name == "packages") {
state->forceAttrs(vProvide, pos);
for (auto & aCheck : *vProvide.attrs)
provide[aCheck.name] = nlohmann::json::object();
}
outputs[name] = provide;
});
json["outputs"] = std::move(outputs);
std::cout << json.dump() << std::endl;
} else {
auto flake = getFlake();
stopProgressBar();
if (json) {
auto json = flakeToJson(*store, flake);
std::cout << json.dump() << std::endl;
} else
printFlakeInfo(*store, flake);
}
}
};
struct CmdFlakeListInputs : FlakeCommand, MixJSON