mirror of
https://github.com/NixOS/nix
synced 2025-07-06 00:51:47 +02:00
nix-instantiate: Add a flag --expr / -E to read expressions from the command line
This is basically a shortcut for ‘echo 'expr...' | nix-instantiate -’. Also supported by nix-build and nix-shell.
This commit is contained in:
parent
e707a8a526
commit
c31836008e
6 changed files with 148 additions and 95 deletions
|
@ -89,6 +89,7 @@ void run(Strings args)
|
|||
EvalState state;
|
||||
Strings files;
|
||||
bool readStdin = false;
|
||||
bool fromArgs = false;
|
||||
bool findFile = false;
|
||||
bool evalOnly = false;
|
||||
bool parseOnly = false;
|
||||
|
@ -104,6 +105,8 @@ void run(Strings args)
|
|||
|
||||
if (arg == "-")
|
||||
readStdin = true;
|
||||
else if (arg == "--expr" || arg == "-E")
|
||||
fromArgs = true;
|
||||
else if (arg == "--eval-only")
|
||||
evalOnly = true;
|
||||
else if (arg == "--read-write-mode")
|
||||
|
@ -162,11 +165,13 @@ void run(Strings args)
|
|||
Expr * e = parseStdin(state);
|
||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
||||
} else if (files.empty())
|
||||
} else if (files.empty() && !fromArgs)
|
||||
files.push_back("./default.nix");
|
||||
|
||||
foreach (Strings::iterator, i, files) {
|
||||
Expr * e = state.parseExprFromFile(resolveExprPath(lookupFileArg(state, *i)));
|
||||
Expr * e = fromArgs
|
||||
? state.parseExprFromString(*i, absPath("."))
|
||||
: state.parseExprFromFile(resolveExprPath(lookupFileArg(state, *i)));
|
||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue