From 3913afdd69a5bd065d6096dd569397a836ac6857 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 27 Oct 2019 17:58:25 +0100 Subject: [PATCH] Simplification --- src/nix-build/nix-build.cc | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 357986980..1c5d71681 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -245,21 +245,17 @@ static void _main(int argc, char * * argv) auto state = std::make_unique(myArgs.searchPath, store); state->repair = repair; - Bindings & autoArgs = *[&](){ - Bindings *userAutoArgs = myArgs.getAutoArgs(*state); - if (runEnv) { - Bindings * res = state->allocBindings(userAutoArgs->size() + 1); - Value * tru = state->allocValue(); - mkBool(*tru, true); - res->push_back(Attr(state->symbols.create("inNixShell"), tru)); - for (auto & i : *userAutoArgs) { - res->push_back(i); - } - res->sort(); - return res; - } - else return userAutoArgs; - }(); + auto autoArgs = myArgs.getAutoArgs(*state); + + if (runEnv) { + auto newArgs = state->allocBindings(autoArgs->size() + 1); + auto tru = state->allocValue(); + mkBool(*tru, true); + newArgs->push_back(Attr(state->symbols.create("inNixShell"), tru)); + for (auto & i : *autoArgs) newArgs->push_back(i); + newArgs->sort(); + autoArgs = newArgs; + } if (packages) { std::ostringstream joined; @@ -313,9 +309,9 @@ static void _main(int argc, char * * argv) state->eval(e, vRoot); for (auto & i : attrPaths) { - Value & v(*findAlongAttrPath(*state, i, autoArgs, vRoot)); + Value & v(*findAlongAttrPath(*state, i, *autoArgs, vRoot)); state->forceValue(v); - getDerivations(*state, v, "", autoArgs, drvs, false); + getDerivations(*state, v, "", *autoArgs, drvs, false); } }