Fixes #176.
7GKAIP3VYKM4MGGHOGBB3DR2M6B6SENBR5IZQVJYO65AWT4BW7LAC
WMWBCZPRDLX57HUCWCOVIYOYGEQGOVL3PQW67F327RD77FD5D2JAC
FGUL3HAZDA6JGTAZNCJZIIKALZ4VMVTXYWFNSXWDYR5LXNGCO3RAC
7D6RFSAAPJMO256QSOSDP3C7Z4GN377H7EM42QQ2TRGPTTVZ4OSQC
4N5APGRGHTKFMEJ7THSJX6TSYYAP3BUZQG73AJBKCQLXOOEHPATQC
4LWGZL33NOCTVZXUZZM5P6BRBHDUMEAJPVPNB52PN3UZVC7DMSZAC
A63IHCMXH3F4V56HDXJLJVVHKXRSJCJMT2PWXXI2IW3J734J6SGQC
3PNG7NIBQQURUUPRVQXYL342OT7JUUYOMY2JJNP6YDX7SYJDZMYAC
AEKIREIHNEHL4CQEHRZJGRWMCV2XO6ICZK2OM342IKAJV6MUMDOAC
SM5M2J3AGBS4IHD7TBFBVNMXTUBVA5OIFIIJJDAU6KUCPRU4S74AC
7YCFGMZBCWDOOO3DHSJ3ZWPUWFMEO6OLQGDZWLULAPER3YZOYUJAC
KD5237CUR4X3VRUD46H3CVU22NYS7LOPF3WXENWHNSF7GKEIQZ6QC
AEFNBIIWLCTYPU6PDYG6D7OYGVP3E7DAGMYPIXVKCVVHJAM63FNAC
52JSLNC6VRUY6JFXWYMH7LR6NUBPC3ENL4VI75NOMFRNDWT3T2JQC
POPU2ATH2HHBTGHKRAV3EY2K55P664IARI3YJGLDKVJ6PQPXBQ4AC
77VF5TC64OAL6CNIDZL7RO3UAAB4Y7CIMWBZGDKL7Z3AGI4DRGGAC
MIC2O6ZFPPBE77F527U7ZEA5Y4SAG53CUX2ZZA76DGV64D5N2GRAC
/* FIXME: hack */
Strings searchPath;
Strings args2;
for (Strings::iterator i = args.begin(); i != args.end(); ) {
string arg = *i++;
if (!parseSearchPathArg(arg, i, args.end(), searchPath))
args2.push_back(arg);
}
args = args2;
EvalState state(searchPath);
Path releaseExpr;
AutoArgs autoArgs;
return handleExceptions(argv[0], [&]() {
initNix();
for (Strings::iterator i = args.begin(); i != args.end(); ) {
string arg = *i++;
if (arg == "--arg" || arg == "--argstr") {
/* This is like --arg in nix-instantiate, except that it
supports multiple versions for the same argument.
That is, autoArgs is a mapping from variable names to
*lists* of values. */
if (i == args.end()) throw UsageError("missing argument");
string name = *i++;
if (i == args.end()) throw UsageError("missing argument");
string value = *i++;
Value * v = state.allocValue();
if (arg == "--arg")
state.eval(state.parseExprFromString(value, absPath(".")), *v);
Strings searchPath;
Path releaseExpr;
std::map<string, Strings> autoArgs_;
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
if (*arg == "--arg" || *arg == "--argstr") {
/* This is like --arg in nix-instantiate, except that it
supports multiple versions for the same argument.
That is, autoArgs is a mapping from variable names to
*lists* of values. */
auto what = *arg;
string name = getArg(what, arg, end);
string value = getArg(what, arg, end);
autoArgs_[name].push_back((what == "--arg" ? 'E' : 'S') + value);
}
else if (parseSearchPathArg(arg, end, searchPath))
;
else if (*arg == "--gc-roots-dir")
gcRootsDir = getArg(*arg, arg, end);
else if (*arg != "" && arg->at(0) == '-')
return false;
mkString(*v, value);
autoArgs[state.symbols.create(name)].push_back(v);
}
else if (arg == "--gc-roots-dir") {
if (i == args.end()) throw UsageError("missing argument");
gcRootsDir = *i++;
}
else if (arg[0] == '-')
throw UsageError(format("unknown flag `%1%'") % arg);
else
releaseExpr = arg;
}
releaseExpr = absPath(*arg);
return true;
});
Value v;
state.evalFile(releaseExpr, v);
AutoArgs autoArgs;
for (auto & i : autoArgs_) {
for (auto & j : i.second) {
Value * v = state.allocValue();
if (j[0] == 'E')
state.eval(state.parseExprFromString(string(j, 1), absPath(".")), *v);
else
mkString(*v, string(j, 1));
autoArgs[state.symbols.create(i.first)].push_back(v);
}
}
//evalAutoArgs(state, autoArgs_, autoArgs);