about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nix-env/help.txt14
-rw-r--r--src/nix-env/nix-env.cc8
2 files changed, 16 insertions, 6 deletions
diff --git a/src/nix-env/help.txt b/src/nix-env/help.txt
index 534d16ad3c56..16e47a73e3ac 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 5dab2e60b2d0..77b7881711e4 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));