diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-24T11·01+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-24T11·01+0000 |
commit | b8572678930568efcf0b44523e6a2a65afef7c43 (patch) | |
tree | 6ebff990cb3ae9e5027d6593aa1d826453311ae2 | |
parent | 496934a99ce509ac94a99a938d7d79d1b38461ef (diff) |
* Allow the top-level expression to be a derivation.
* Hack: `nix-env -i *' installs all available derivations.
-rw-r--r-- | src/nix-env/main.cc | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index b3c38616ec2f..3c72a7950727 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -53,15 +53,17 @@ bool parseDerivations(EvalState & state, Expr e, DrvInfos & drvs) { ATMatcher m; ATermList es; + DrvInfo drv; e = evalExpr(state, e); - - if (atMatch(m, e) >> "Attrs") { + + if (parseDerivation(state, e, drv)) + drvs[drv.drvPath] = drv; + + else if (atMatch(m, e) >> "Attrs") { ATermMap drvMap; queryAllAttrs(e, drvMap); - for (ATermIterator i(drvMap.keys()); i; ++i) { - DrvInfo drv; debug(format("evaluating attribute `%1%'") % *i); if (parseDerivation(state, drvMap.get(*i), drv)) drvs[drv.drvPath] = drv; @@ -70,7 +72,6 @@ bool parseDerivations(EvalState & state, Expr e, DrvInfos & drvs) else if (atMatch(m, e) >> "List" >> es) { for (ATermIterator i(es); i; ++i) { - DrvInfo drv; debug(format("evaluating list element")); if (parseDerivation(state, *i, drv)) drvs[drv.drvPath] = drv; @@ -243,14 +244,18 @@ void installDerivations(EvalState & state, /* Filter out the ones we're not interested in. */ DrvInfos selectedDrvs; - for (Strings::iterator i = drvNames.begin(); - i != drvNames.end(); ++i) - { - NameMap::iterator j = nameMap.find(*i); - if (j == nameMap.end()) - throw Error(format("unknown derivation `%1%'") % *i); - else - selectedDrvs[j->second] = availDrvs[j->second]; + if (drvNames.size() > 0 && drvNames.front() == "*") { /* !!! hack */ + selectedDrvs = availDrvs; + } else { + for (Strings::iterator i = drvNames.begin(); + i != drvNames.end(); ++i) + { + NameMap::iterator j = nameMap.find(*i); + if (j == nameMap.end()) + throw Error(format("unknown derivation `%1%'") % *i); + else + selectedDrvs[j->second] = availDrvs[j->second]; + } } /* Add in the already installed derivations. */ |