* In nix-instantiate, at top-level, call functions that have arguments

with default values automatically.  I.e., e -> e {}.

  This feature makes convenience expressions such as
  pkgs/system/i686-linux.nix in Nixpkgs obsolete, since we can just do

  $ nix-instantiate ./pkgs/system/all-packages.nix

  since all-packages.nix takes a single argument (system) that has a
  default value (__thisSystem).
This commit is contained in:
Eelco Dolstra 2005-07-12 16:06:25 +00:00
parent 928a7c06dc
commit 22d3587f3b

View file

@ -73,6 +73,23 @@ static void printDrvPaths(EvalState & state, Expr e)
return;
}
ATermList formals;
ATerm body, pos;
if (matchFunction(e, formals, body, pos)) {
for (ATermIterator i(formals); i; ++i) {
Expr name, def;
if (matchNoDefFormal(*i, name))
throw Error(format("expression evaluates to a function with no-default arguments (`%1%')")
% aterm2String(name));
else if (!matchDefFormal(*i, name, def))
abort(); /* can't happen */
}
printDrvPaths(state, evalExpr(state,
makeCall(e, makeAttrs(ATermMap()))));
return;
}
throw Error("expression does not evaluate to one or more derivations");
}