about summary refs log tree commit diff
path: root/src/nix-env/nix-env.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-04-26T14·20+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-04-26T14·20+0000
commitb7f0f65c1934851b038826b2ab78c0378a36143a (patch)
tree3712f11db4838e8ba0ce898d71244982b60b028d /src/nix-env/nix-env.cc
parent5dc05b76ab88a332521a777d6a42974b3f432f02 (diff)
* 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.

Diffstat (limited to 'src/nix-env/nix-env.cc')
-rw-r--r--src/nix-env/nix-env.cc8
1 files changed, 8 insertions, 0 deletions
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));