about summary refs log tree commit diff
path: root/src/nix/command.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/command.cc')
-rw-r--r--src/nix/command.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/nix/command.cc b/src/nix/command.cc
index a89246a937c1..986953fd845d 100644
--- a/src/nix/command.cc
+++ b/src/nix/command.cc
@@ -73,18 +73,28 @@ StorePathsCommand::StorePathsCommand()
 {
     expectArgs("paths", &storePaths);
     mkFlag('r', "recursive", "apply operation to closure of the specified paths", &recursive);
+    mkFlag(0, "all", "apply operation to the entire store", &all);
 }
 
 void StorePathsCommand::run(ref<Store> store)
 {
-    for (auto & storePath : storePaths)
-        storePath = followLinksToStorePath(storePath);
+    if (all) {
+        if (storePaths.size())
+            throw UsageError("‘--all’ does not expect arguments");
+        for (auto & p : store->queryAllValidPaths())
+            storePaths.push_back(p);
+    }
 
-    if (recursive) {
-        PathSet closure;
+    else {
         for (auto & storePath : storePaths)
-            store->computeFSClosure(storePath, closure, false, false);
-        storePaths = store->topoSortPaths(closure);
+            storePath = followLinksToStorePath(storePath);
+
+        if (recursive) {
+            PathSet closure;
+            for (auto & storePath : storePaths)
+                store->computeFSClosure(storePath, closure, false, false);
+            storePaths = store->topoSortPaths(closure);
+        }
     }
 
     run(store, storePaths);