From b7f0f65c1934851b038826b2ab78c0378a36143a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 26 Apr 2007 14:20:31 +0000 Subject: [PATCH] =?UTF-8?q?*=20nix-env=20-q=20now=20has=20a=20flag=20--pre?= =?UTF-8?q?built-only=20(-b<)=20that=20causes=20nix-env=20=20=20to=20show?= =?UTF-8?q?=20only=20those=20derivations=20whose=20output=20is=20already?= =?UTF-8?q?=20in=20the=20Nix=20=20=20store=20or=20that=20can=20be=20substi?= =?UTF-8?q?tuted=20(i.e.,=20downloaded=20from=20somewhere).=20=20=20In=20o?= =?UTF-8?q?ther=20words,=20it=20shows=20the=20packages=20that=20can=20be?= =?UTF-8?q?=20installed=20=E2=80=9Cquickly=E2=80=9D,=20=20=20i.e.,=20don?= =?UTF-8?q?=E2=80=99t=20need=20to=20be=20built=20from=20source.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/manual/release-notes.xml | 9 +++++++++ src/nix-env/help.txt | 14 ++++++++------ src/nix-env/nix-env.cc | 8 ++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/doc/manual/release-notes.xml b/doc/manual/release-notes.xml index 4830b323ef..e5d0adf74b 100644 --- a/doc/manual/release-notes.xml +++ b/doc/manual/release-notes.xml @@ -74,6 +74,15 @@ . + nix-env -q now has a flag + () 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. + + TODO: new built-ins builtins.attrNames, builtins.filterSource, diff --git a/src/nix-env/help.txt b/src/nix-env/help.txt index 534d16ad3c..16e47a73e3 100644 --- a/src/nix-env/help.txt +++ b/src/nix-env/help.txt @@ -45,7 +45,12 @@ Upgrade flags: --eq: "upgrade" if the current version is equal --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 --no-name: hide derivation names @@ -55,11 +60,8 @@ Query types: --compare-versions / -c: compare version to available or installed --drv-path: print path of derivation --out-path: print path of derivation output - -Query sources: - - --installed: use installed derivations (default) - --available / -a: use derivations available in Nix expression + --prebuilt-only: only show derivations whose prebuilt binaries are + available on this machine or are downloadable Options: diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 5dab2e60b2..77b7881711 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -831,6 +831,7 @@ static void opQuery(Globals & globals, bool printDrvPath = false; bool printOutPath = false; bool printDescription = false; + bool prebuiltOnly = false; bool compareVersions = false; bool xmlOutput = false; @@ -849,6 +850,7 @@ static void opQuery(Globals & globals, else if (*i == "--out-path") printOutPath = true; else if (*i == "--installed") source = sInstalled; else if (*i == "--available" || *i == "-a") source = sAvailable; + else if (*i == "--prebuilt-only" || *i == "-b") prebuiltOnly = true; else if (*i == "--xml") xmlOutput = true; else throw UsageError(format("unknown flag `%1%'") % *i); @@ -914,6 +916,12 @@ static void opQuery(Globals & globals, /* For XML output. */ XMLAttrs attrs; + + if (prebuiltOnly) { + if (!store->isValidPath(i->queryOutPath(globals.state)) && + !store->hasSubstitutes(i->queryOutPath(globals.state))) + continue; + } if (printStatus) { bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state));