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,39 +153,14 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
void run(nix::ref<nix::Store> store) override void run(nix::ref<nix::Store> store) override
{ {
auto flake = getFlake();
stopProgressBar();
if (json) { if (json) {
auto state = getEvalState(); auto json = flakeToJson(*store, flake);
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; std::cout << json.dump() << std::endl;
} else { } else
auto flake = getFlake();
stopProgressBar();
printFlakeInfo(*store, flake); printFlakeInfo(*store, flake);
}
} }
}; };