* Added an installation source --from-expression' (or
-E') to
install derivations from a Nix expression specified on the command line. This is particularly useful for disambiguation if there are multiple derivations with the same name. For instance, in Nixpkgs, to install the Firefox wrapper rather than the plain Firefox component: $ nix-env -f .../i686-linux.nix -i -E 'x: x.firefoxWrapper' The Nix expressions should be functions to which the default Nix expression (in this case, `i686-linux.nix') is passed, hence `x: ...'. This might also be a nice way to deal with high-level (user-level) variability, e.g., $ nix-env -f ./server.nix -i -E 'x: x {port = 8080; ssl = false;}'
This commit is contained in:
parent
0cb016c209
commit
e446d342b7
|
@ -91,7 +91,7 @@ static bool parseDerivation(EvalState & state, Expr e, UserEnvElem & elem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool parseDerivations(EvalState & state, Expr e, UserEnvElems & elems)
|
static void parseDerivations(EvalState & state, Expr e, UserEnvElems & elems)
|
||||||
{
|
{
|
||||||
ATermList es;
|
ATermList es;
|
||||||
UserEnvElem elem;
|
UserEnvElem elem;
|
||||||
|
@ -122,17 +122,14 @@ static bool parseDerivations(EvalState & state, Expr e, UserEnvElems & elems)
|
||||||
parseDerivations(state, *i, elems);
|
parseDerivations(state, *i, elems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void loadDerivations(EvalState & state, Path nixExprPath,
|
static void loadDerivations(EvalState & state, Path nixExprPath,
|
||||||
string systemFilter, UserEnvElems & elems)
|
string systemFilter, UserEnvElems & elems)
|
||||||
{
|
{
|
||||||
Expr e = parseExprFromFile(state, absPath(nixExprPath));
|
parseDerivations(state,
|
||||||
if (!parseDerivations(state, e, elems))
|
parseExprFromFile(state, absPath(nixExprPath)), elems);
|
||||||
throw Error("set of derivations expected");
|
|
||||||
|
|
||||||
/* Filter out all derivations not applicable to the current
|
/* Filter out all derivations not applicable to the current
|
||||||
system. */
|
system. */
|
||||||
|
@ -185,8 +182,7 @@ static void queryInstalled(EvalState & state, UserEnvElems & elems,
|
||||||
AddPos addPos;
|
AddPos addPos;
|
||||||
e = bottomupRewrite(addPos, e);
|
e = bottomupRewrite(addPos, e);
|
||||||
|
|
||||||
if (!parseDerivations(state, e, elems))
|
parseDerivations(state, e, elems);
|
||||||
throw badTerm(format("set of derivations expected in `%1%'") % path, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,7 +311,25 @@ static void queryInstSources(EvalState & state,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the available user environment elements from the Nix
|
||||||
|
expressions specified on the command line; these should be
|
||||||
|
functions that take the default Nix expression file as
|
||||||
|
argument, e.g., if the file is `./foo.nix', then the
|
||||||
|
argument `x: x.bar' is equivalent to `(x: x.bar)
|
||||||
|
(import ./foo.nix)' = `(import ./foo.nix).bar'. */
|
||||||
case srcNixExprs:
|
case srcNixExprs:
|
||||||
|
|
||||||
|
Expr e1 = parseExprFromFile(state,
|
||||||
|
absPath(instSource.nixExprPath));
|
||||||
|
|
||||||
|
for (Strings::const_iterator i = args.begin();
|
||||||
|
i != args.end(); ++i)
|
||||||
|
{
|
||||||
|
Expr e2 = parseExprFromString(state, *i, absPath("."));
|
||||||
|
Expr call = makeCall(e2, e1);
|
||||||
|
parseDerivations(state, call, elems);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case srcStorePaths:
|
case srcStorePaths:
|
||||||
|
|
Loading…
Reference in a new issue