aboutsummaryrefslogtreecommitdiff
path: root/src/nix/flake.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-09-22 21:53:01 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-09-22 21:53:01 +0200
commit382aa05ff71b61379f5c2792eaf517bdf4a5c5bf (patch)
tree09e72863748c61f313b26c0ef64157442dbc6a9a /src/nix/flake.cc
parent893be6f5e36abb58bbaa9c49055a5218114dd514 (diff)
nix flake info --json: Get rid of duplicate getFlake() call
Also fix some gcc warnings.
Diffstat (limited to 'src/nix/flake.cc')
-rw-r--r--src/nix/flake.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 2e352306e..d0135143c 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -174,11 +174,12 @@ static void enumerateOutputs(EvalState & state, Value & vFlake,
{
state.forceAttrs(vFlake);
- auto vOutputs = (*vFlake.attrs->get(state.symbols.create("outputs")))->value;
+ auto aOutputs = vFlake.attrs->get(state.symbols.create("outputs"));
+ assert(aOutputs);
- state.forceAttrs(*vOutputs);
+ state.forceAttrs(*(*aOutputs)->value);
- for (auto & attr : *vOutputs->attrs)
+ for (auto & attr : *((*aOutputs)->value->attrs))
callback(attr.name, *attr.value, *attr.pos);
}
@@ -191,15 +192,12 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
void run(nix::ref<nix::Store> store) override
{
- auto flake = getFlake();
- stopProgressBar();
-
if (json) {
- auto json = flakeToJson(flake);
-
auto state = getEvalState();
auto flake = resolveFlake();
+ auto json = flakeToJson(flake.flake);
+
auto vFlake = state->allocValue();
flake::callFlake(*state, flake, *vFlake);
@@ -222,8 +220,11 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
json["outputs"] = std::move(outputs);
std::cout << json.dump() << std::endl;
- } else
+ } else {
+ auto flake = getFlake();
+ stopProgressBar();
printFlakeInfo(flake);
+ }
}
};