* Allow --arg in nix-env as well, example:

$ nix-env -qa --system-filter \* --arg system '"powerpc-darwin"'

  to override the system from the default value (__currentSystem in
  all-packages.nix).
This commit is contained in:
Eelco Dolstra 2006-08-23 16:33:21 +00:00
parent 9638f3f393
commit f41297fdce
2 changed files with 37 additions and 17 deletions

View file

@ -47,8 +47,8 @@ irreversible.</para></warning>
<literal>references</literal> table (i.e., it tells you what store <literal>references</literal> table (i.e., it tells you what store
paths refer to a given path). Maintaining this table could take a paths refer to a given path). Maintaining this table could take a
quadratic amount of time, as well as a quadratic amount of Berkeley quadratic amount of time, as well as a quadratic amount of Berkeley
DB log file space (in particular when running the garbage DB log file space (in particular when running the garbage collector)
collector).</para></listitem> (<literal>NIX-23</literal>).</para></listitem>
<listitem><para>Nix now catches the <literal>TERM</literal> and <listitem><para>Nix now catches the <literal>TERM</literal> and
<literal>HUP</literal> signals in addition to the <literal>HUP</literal> signals in addition to the
@ -85,7 +85,8 @@ irreversible.</para></warning>
(<literal>~</literal>) has been deprecated.</para></listitem> (<literal>~</literal>) has been deprecated.</para></listitem>
<listitem><para>TODO: function argument default values can refer <listitem><para>TODO: function argument default values can refer
to other function arguments</para></listitem> to other function arguments
(<literal>NIX-45</literal>)</para></listitem>
<listitem><para>TODO: domain checks (r5895).</para></listitem> <listitem><para>TODO: domain checks (r5895).</para></listitem>
@ -148,7 +149,18 @@ irreversible.</para></warning>
<itemizedlist> <itemizedlist>
<listitem><para>Make sure that the garbage collector can run <listitem><para>Make sure that the garbage collector can run
succesfully when the disk is full.</para></listitem> succesfully when the disk is full
(<literal>NIX-18</literal>).</para></listitem>
<listitem><para><command>nix-env</command> now locks the profile
to prevent races between concurrent <command>nix-env</command>
operations on the same profile
(<literal>NIX-7</literal>).</para></listitem>
<listitem><para>Removed misleading messages from
<literal>nix-env -i</literal> (e.g., <literal>installing
`foo'</literal> followed by <literal>uninstalling
`foo'</literal>) (<literal>NIX-17</literal>).</para></listitem>
</itemizedlist> </itemizedlist>
@ -162,7 +174,7 @@ irreversible.</para></warning>
<replaceable>pkgname</replaceable></literal> will now install the <replaceable>pkgname</replaceable></literal> will now install the
highest available version of <replaceable>pkgname</replaceable>, highest available version of <replaceable>pkgname</replaceable>,
rather than installing all available versions (which would probably rather than installing all available versions (which would probably
give collisions).</para></listitem> give collisions) (<literal>NIX-31</literal>).</para></listitem>
<listitem><para><literal>nix-env (-i|-u) --dry-run</literal> now <listitem><para><literal>nix-env (-i|-u) --dry-run</literal> now
shows exactly which missing paths will be built or shows exactly which missing paths will be built or
@ -185,11 +197,6 @@ irreversible.</para></warning>
<literal>i686-cygwin</literal>) and Mac OS X on Intel <literal>i686-cygwin</literal>) and Mac OS X on Intel
(<literal>i686-darwin</literal>).</para></listitem> (<literal>i686-darwin</literal>).</para></listitem>
<listitem><para><command>nix-env</command> now locks the profile to
prevent races between concurrent <command>nix-env</command>
operations on the same profile
(<literal>NIX-7</literal>).</para></listitem>
<listitem><para>TODO: <literal>nix-push <listitem><para>TODO: <literal>nix-push
--target</literal>.</para></listitem> --target</literal>.</para></listitem>

View file

@ -39,6 +39,8 @@ struct InstallSourceInfo
Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */ Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */
Path profile; /* for srcProfile */ Path profile; /* for srcProfile */
string systemFilter; /* for srcNixExprDrvs */ string systemFilter; /* for srcNixExprDrvs */
ATermMap autoArgs;
InstallSourceInfo() : autoArgs(128) { };
}; };
@ -64,10 +66,10 @@ void printHelp()
static void loadDerivations(EvalState & state, Path nixExprPath, static void loadDerivations(EvalState & state, Path nixExprPath,
string systemFilter, DrvInfos & elems) string systemFilter, const ATermMap & autoArgs, DrvInfos & elems)
{ {
getDerivations(state, getDerivations(state,
parseExprFromFile(state, absPath(nixExprPath)), "", ATermMap(1), elems); parseExprFromFile(state, absPath(nixExprPath)), "", autoArgs, elems);
/* Filter out all derivations not applicable to the current /* Filter out all derivations not applicable to the current
system. */ system. */
@ -312,7 +314,7 @@ static void queryInstSources(EvalState & state,
Nix expression. */ Nix expression. */
DrvInfos allElems; DrvInfos allElems;
loadDerivations(state, instSource.nixExprPath, loadDerivations(state, instSource.nixExprPath,
instSource.systemFilter, allElems); instSource.systemFilter, instSource.autoArgs, allElems);
elems = filterBySelector(state, allElems, args, newestOnly); elems = filterBySelector(state, allElems, args, newestOnly);
@ -336,7 +338,7 @@ static void queryInstSources(EvalState & state,
{ {
Expr e2 = parseExprFromString(state, *i, absPath(".")); Expr e2 = parseExprFromString(state, *i, absPath("."));
Expr call = makeCall(e2, e1); Expr call = makeCall(e2, e1);
getDerivations(state, call, "", ATermMap(1), elems); getDerivations(state, call, "", instSource.autoArgs, elems);
} }
break; break;
@ -390,9 +392,9 @@ static void queryInstSources(EvalState & state,
for (Strings::const_iterator i = args.begin(); for (Strings::const_iterator i = args.begin();
i != args.end(); ++i) i != args.end(); ++i)
getDerivations(state, getDerivations(state,
findAlongAttrPath(state, *i, findAlongAttrPath(state, *i, instSource.autoArgs,
parseExprFromFile(state, instSource.nixExprPath)), parseExprFromFile(state, instSource.nixExprPath)),
"", ATermMap(1), elems); "", instSource.autoArgs, elems);
break; break;
} }
} }
@ -772,7 +774,8 @@ static void opQuery(Globals & globals,
if (source == sAvailable || compareVersions) { if (source == sAvailable || compareVersions) {
loadDerivations(globals.state, globals.instSource.nixExprPath, loadDerivations(globals.state, globals.instSource.nixExprPath,
globals.instSource.systemFilter, availElems); globals.instSource.systemFilter, globals.instSource.autoArgs,
availElems);
} }
DrvInfos elems = filterBySelector(globals.state, DrvInfos elems = filterBySelector(globals.state,
@ -1115,6 +1118,16 @@ void run(Strings args)
} }
else if (arg == "--attr" || arg == "-A") else if (arg == "--attr" || arg == "-A")
globals.instSource.type = srcAttrPath; globals.instSource.type = srcAttrPath;
else if (arg == "--arg") { /* !!! code duplication from nix-instantiate */
i++;
if (i == args.end())
throw UsageError("`--arg' requires two arguments");
string name = *i++;
if (i == args.end())
throw UsageError("`--arg' requires two arguments");
Expr value = parseExprFromString(globals.state, *i, absPath("."));
globals.instSource.autoArgs.set(toATerm(name), value);
}
else if (arg == "--uninstall" || arg == "-e") else if (arg == "--uninstall" || arg == "-e")
op = opUninstall; op = opUninstall;
else if (arg == "--upgrade" || arg == "-u") else if (arg == "--upgrade" || arg == "-u")