aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-10-24 12:45:11 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-10-24 12:58:34 +0200
commit0d59f1ca49c9f7f3b2edaadcf590360ec66a6257 (patch)
treea03d53d84fb61eb354e2634705d8a076f0c1c76d /src/nix-build
parent25f32625e2f2a3a1e1b3a3811da82f21c3a3b880 (diff)
nix: Respect -I, --arg, --argstr
Also, random cleanup to argument handling.
Diffstat (limited to 'src/nix-build')
-rwxr-xr-xsrc/nix-build/nix-build.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 4541c89a7..85137206f 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -14,7 +14,7 @@
#include "eval.hh"
#include "eval-inline.hh"
#include "get-drvs.hh"
-#include "common-opts.hh"
+#include "common-eval-args.hh"
#include "attr-path.hh"
using namespace nix;
@@ -80,8 +80,6 @@ void mainWrapped(int argc, char * * argv)
auto interactive = isatty(STDIN_FILENO) && isatty(STDERR_FILENO);
Strings attrPaths;
Strings left;
- Strings searchPath;
- std::map<string, string> autoArgs_;
RepairFlag repair = NoRepair;
Path gcRoot;
BuildMode buildMode = bmNormal;
@@ -129,7 +127,12 @@ void mainWrapped(int argc, char * * argv)
} catch (SysError &) { }
}
- parseCmdLine(myName, args, [&](Strings::iterator & arg, const Strings::iterator & end) {
+ struct MyArgs : LegacyArgs, MixEvalArgs
+ {
+ using LegacyArgs::LegacyArgs;
+ };
+
+ MyArgs myArgs(myName, [&](Strings::iterator & arg, const Strings::iterator & end) {
if (*arg == "--help") {
deletePath(tmpDir);
showManPage(myName);
@@ -153,12 +156,6 @@ void mainWrapped(int argc, char * * argv)
else if (*arg == "--out-link" || *arg == "-o")
outLink = getArg(*arg, arg, end);
- else if (parseAutoArgs(arg, end, autoArgs_))
- ;
-
- else if (parseSearchPathArg(arg, end, searchPath))
- ;
-
else if (*arg == "--add-root")
gcRoot = getArg(*arg, arg, end);
@@ -237,15 +234,17 @@ void mainWrapped(int argc, char * * argv)
return true;
});
+ myArgs.parseCmdline(args);
+
if (packages && fromArgs)
throw UsageError("'-p' and '-E' are mutually exclusive");
auto store = openStore();
- EvalState state(searchPath, store);
+ EvalState state(myArgs.searchPath, store);
state.repair = repair;
- Bindings & autoArgs(*evalAutoArgs(state, autoArgs_));
+ Bindings & autoArgs = *myArgs.getAutoArgs(state);
if (packages) {
std::ostringstream joined;