diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-02-10 17:25:59 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-02-10 17:25:59 +0000 |
commit | c6120352b3fd25380ff21726982e22b97ee43e0b (patch) | |
tree | 5d8ac14dd44ef25ea0bf3a53490dbe9f31969793 /src/nix-instantiate | |
parent | b505f9eaf57c7badeacb176a1946b5f5f145f816 (diff) |
* In nix-instantiate, allow us to specify a "path" to the
derivation(s) we're interested, e.g.,
$ nix-instantiate ./all-packages.nix --attr xlibs.libX11
List elements can also be selected:
$ nix-instantiate ./build-for-release.nix --attr 0.subversion
This allows a non-ambiguous specification of a derivation. Of
course, this should also be added to nix-env and nix-build.
Diffstat (limited to 'src/nix-instantiate')
-rw-r--r-- | src/nix-instantiate/main.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nix-instantiate/main.cc b/src/nix-instantiate/main.cc index 75d03f329..7668958fc 100644 --- a/src/nix-instantiate/main.cc +++ b/src/nix-instantiate/main.cc @@ -33,13 +33,14 @@ static int rootNr = 0; static bool indirectRoot = false; -static void printResult(EvalState & state, Expr e, bool evalOnly) +static void printResult(EvalState & state, Expr e, bool evalOnly, + const string & attrPath) { if (evalOnly) cout << format("%1%\n") % e; else { DrvInfos drvs; - getDerivations(state, e, drvs); + getDerivations(state, e, drvs, attrPath); for (DrvInfos::iterator i = drvs.begin(); i != drvs.end(); ++i) { Path drvPath = i->queryDrvPath(state); if (gcRoot == "") @@ -61,6 +62,7 @@ void run(Strings args) bool readStdin = false; bool evalOnly = false; bool parseOnly = false; + string attrPath; for (Strings::iterator i = args.begin(); i != args.end(); ) @@ -82,6 +84,11 @@ void run(Strings args) throw UsageError("`--add-root requires an argument"); gcRoot = absPath(*i++); } + else if (arg == "--attr") { + if (i == args.end()) + throw UsageError("`--attr requires an argument"); + attrPath = *i++; + } else if (arg == "--indirect") indirectRoot = true; else if (arg[0] == '-') @@ -94,7 +101,7 @@ void run(Strings args) if (readStdin) { Expr e = evalStdin(state, parseOnly); - printResult(state, e, evalOnly); + printResult(state, e, evalOnly, attrPath); } for (Strings::iterator i = files.begin(); @@ -104,7 +111,7 @@ void run(Strings args) Expr e = parseOnly ? parseExprFromFile(state, path) : evalFile(state, path); - printResult(state, e, evalOnly); + printResult(state, e, evalOnly, attrPath); } printEvalStats(state); |