about summary refs log tree commit diff
path: root/src/nix/verify.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-03-29T12·49+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-03-29T14·37+0200
commit4f34c403980e7f5ae3d5257b742af6fd6452c6cf (patch)
tree7c48ecfa0f1e4eabaf65f353eadb30a1efcdd4df /src/nix/verify.cc
parent784ee35c80774c5f073b6b8be6ab3d4d7e38e2f1 (diff)
Add "nix verify-store" command
Like "nix-store --verify --check-contents", but with the same
advantages as "nix verify-paths".
Diffstat (limited to 'src/nix/verify.cc')
-rw-r--r--src/nix/verify.cc66
1 files changed, 53 insertions, 13 deletions
diff --git a/src/nix/verify.cc b/src/nix/verify.cc
index ef3e9fcc27ff..1bd2a000a3ee 100644
--- a/src/nix/verify.cc
+++ b/src/nix/verify.cc
@@ -10,28 +10,18 @@
 
 using namespace nix;
 
-struct CmdVerifyPaths : StorePathsCommand
+struct MixVerify : virtual Args
 {
     bool noContents = false;
     bool noSigs = false;
 
-    CmdVerifyPaths()
+    MixVerify()
     {
         mkFlag(0, "no-contents", "do not verify the contents of each store path", &noContents);
         mkFlag(0, "no-sigs", "do not verify whether each store path has a valid signature", &noSigs);
     }
 
-    std::string name() override
-    {
-        return "verify-paths";
-    }
-
-    std::string description() override
-    {
-        return "verify the integrity of store paths";
-    }
-
-    void run(ref<Store> store, Paths storePaths) override
+    void verifyPaths(ref<Store> store, const Paths & storePaths)
     {
         restoreAffinity(); // FIXME
 
@@ -121,4 +111,54 @@ struct CmdVerifyPaths : StorePathsCommand
     }
 };
 
+struct CmdVerifyPaths : StorePathsCommand, MixVerify
+{
+    CmdVerifyPaths()
+    {
+    }
+
+    std::string name() override
+    {
+        return "verify-paths";
+    }
+
+    std::string description() override
+    {
+        return "verify the integrity of store paths";
+    }
+
+    void run(ref<Store> store, Paths storePaths) override
+    {
+        verifyPaths(store, storePaths);
+    }
+};
+
 static RegisterCommand r1(make_ref<CmdVerifyPaths>());
+
+struct CmdVerifyStore : StoreCommand, MixVerify
+{
+    CmdVerifyStore()
+    {
+    }
+
+    std::string name() override
+    {
+        return "verify-store";
+    }
+
+    std::string description() override
+    {
+        return "verify the integrity of all paths in the Nix store";
+    }
+
+    void run(ref<Store> store) override
+    {
+        // FIXME: use store->verifyStore()?
+
+        PathSet validPaths = store->queryAllValidPaths();
+
+        verifyPaths(store, Paths(validPaths.begin(), validPaths.end()));
+    }
+};
+
+static RegisterCommand r2(make_ref<CmdVerifyStore>());