* nix-env -q now has a flag --prebuilt-only (-b<) that causes nix-env

to show only those derivations whose output is already in the Nix
  store or that can be substituted (i.e., downloaded from somewhere).
  In other words, it shows the packages that can be installed “quickly”,
  i.e., don’t need to be built from source.
This commit is contained in:
Eelco Dolstra 2007-04-26 14:20:31 +00:00
parent 5dc05b76ab
commit b7f0f65c19
3 changed files with 25 additions and 6 deletions

View file

@ -74,6 +74,15 @@
<option>--set-flag</option>.</para></listitem> <option>--set-flag</option>.</para></listitem>
<listitem><para><command>nix-env -q</command> now has a flag
<option>--prebuilt-only</option> (<option>-b</option>) that causes
<command>nix-env</command> to show only those derivations whose
output is already in the Nix store or that can be substituted (i.e.,
downloaded from somewhere). In other words, it shows the packages
that can be installed “quickly”, i.e., dont need to be built from
source.</para></listitem>
<listitem><para>TODO: new built-ins <listitem><para>TODO: new built-ins
<function>builtins.attrNames</function>, <function>builtins.attrNames</function>,
<function>builtins.filterSource</function>, <function>builtins.filterSource</function>,

View file

@ -45,7 +45,12 @@ Upgrade flags:
--eq: "upgrade" if the current version is equal --eq: "upgrade" if the current version is equal
--always: upgrade regardless of current version --always: upgrade regardless of current version
Query types: Query sources:
--installed: use installed derivations (default)
--available / -a: use derivations available in Nix expression
Query flags:
--status / -s: print installed/present status --status / -s: print installed/present status
--no-name: hide derivation names --no-name: hide derivation names
@ -55,11 +60,8 @@ Query types:
--compare-versions / -c: compare version to available or installed --compare-versions / -c: compare version to available or installed
--drv-path: print path of derivation --drv-path: print path of derivation
--out-path: print path of derivation output --out-path: print path of derivation output
--prebuilt-only: only show derivations whose prebuilt binaries are
Query sources: available on this machine or are downloadable
--installed: use installed derivations (default)
--available / -a: use derivations available in Nix expression
Options: Options:

View file

@ -831,6 +831,7 @@ static void opQuery(Globals & globals,
bool printDrvPath = false; bool printDrvPath = false;
bool printOutPath = false; bool printOutPath = false;
bool printDescription = false; bool printDescription = false;
bool prebuiltOnly = false;
bool compareVersions = false; bool compareVersions = false;
bool xmlOutput = false; bool xmlOutput = false;
@ -849,6 +850,7 @@ static void opQuery(Globals & globals,
else if (*i == "--out-path") printOutPath = true; else if (*i == "--out-path") printOutPath = true;
else if (*i == "--installed") source = sInstalled; else if (*i == "--installed") source = sInstalled;
else if (*i == "--available" || *i == "-a") source = sAvailable; else if (*i == "--available" || *i == "-a") source = sAvailable;
else if (*i == "--prebuilt-only" || *i == "-b") prebuiltOnly = true;
else if (*i == "--xml") xmlOutput = true; else if (*i == "--xml") xmlOutput = true;
else throw UsageError(format("unknown flag `%1%'") % *i); else throw UsageError(format("unknown flag `%1%'") % *i);
@ -915,6 +917,12 @@ static void opQuery(Globals & globals,
/* For XML output. */ /* For XML output. */
XMLAttrs attrs; XMLAttrs attrs;
if (prebuiltOnly) {
if (!store->isValidPath(i->queryOutPath(globals.state)) &&
!store->hasSubstitutes(i->queryOutPath(globals.state)))
continue;
}
if (printStatus) { if (printStatus) {
bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state)); bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state));
bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end(); bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end();