about summary refs log tree commit diff
path: root/src/nix-store
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 61ae4cf4f925..6399c097468a 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -537,12 +537,23 @@ static void opRegisterValidity(Strings opFlags, Strings opArgs)
 
 static void opCheckValidity(Strings opFlags, Strings opArgs)
 {
-    if (!opFlags.empty()) throw UsageError("unknown flag");
+    bool printInvalid = false;
+    
+    for (Strings::iterator i = opFlags.begin();
+         i != opFlags.end(); ++i)
+        if (*i == "--print-invalid") printInvalid = true;
+        else throw UsageError(format("unknown flag `%1%'") % *i);
 
     for (Strings::iterator i = opArgs.begin();
          i != opArgs.end(); ++i)
-        if (!store->isValidPath(*i))
-            throw Error(format("path `%1%' is not valid") % *i);
+    {
+        Path path = fixPath(*i);
+        if (!store->isValidPath(path))
+            if (printInvalid)
+                cout << format("%1%\n") % path;
+            else
+                throw Error(format("path `%1%' is not valid") % path);
+    }
 }