mirror of
https://github.com/NixOS/nix
synced 2025-06-30 03:23:16 +02:00
* Pass the autoArgs to findAlongAttrPath so that "nix-instantiate
foo.nix -A attr --arg name value" will work if (name, value) is needed in the evaluation leading up to "attr".
This commit is contained in:
parent
b19cebc513
commit
9638f3f393
3 changed files with 11 additions and 7 deletions
|
@ -178,9 +178,10 @@ Expr strictEval(EvalState & state, Expr e)
|
|||
}
|
||||
|
||||
|
||||
Expr doEval(EvalState & state, string attrPath, bool parseOnly, bool strict, Expr e)
|
||||
Expr doEval(EvalState & state, string attrPath, bool parseOnly, bool strict,
|
||||
const ATermMap & autoArgs, Expr e)
|
||||
{
|
||||
e = findAlongAttrPath(state, attrPath, e);
|
||||
e = findAlongAttrPath(state, attrPath, autoArgs, e);
|
||||
if (!parseOnly)
|
||||
if (strict)
|
||||
e = strictEval(state, e);
|
||||
|
@ -229,6 +230,7 @@ void run(Strings args)
|
|||
if (i == args.end())
|
||||
throw UsageError("`--arg' requires two arguments");
|
||||
Expr value = parseExprFromString(state, *i++, absPath("."));
|
||||
printMsg(lvlError, format("X %1% Y %2%") % name % value);
|
||||
autoArgs.set(toATerm(name), value);
|
||||
}
|
||||
else if (arg == "--add-root") {
|
||||
|
@ -252,7 +254,7 @@ void run(Strings args)
|
|||
|
||||
if (readStdin) {
|
||||
Expr e = parseStdin(state);
|
||||
e = doEval(state, attrPath, parseOnly, strict, e);
|
||||
e = doEval(state, attrPath, parseOnly, strict, autoArgs, e);
|
||||
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
||||
}
|
||||
|
||||
|
@ -261,7 +263,7 @@ void run(Strings args)
|
|||
{
|
||||
Path path = absPath(*i);
|
||||
Expr e = parseExprFromFile(state, path);
|
||||
e = doEval(state, attrPath, parseOnly, strict, e);
|
||||
e = doEval(state, attrPath, parseOnly, strict, autoArgs, e);
|
||||
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue