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-04-14T19·14+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-15T13·39+0200
commit99851c6f06c80fe2222c5e5fcef963804e907170 (patch)
treef28eaed5d273ab8ac7d2805dfe36dcb810976f76 /src/nix/verify.cc
parent327569035c70b6171347e5c9c0cd3de4fd7383eb (diff)
Unify "nix verify-paths" and "nix verify-store"
"verify-store" is now simply an "--all" flag to "nix verify". This
flag can be used for any other store path command as well (e.g. "nix
path-info", "nix copy-sigs", ...).
Diffstat (limited to 'src/nix/verify.cc')
-rw-r--r--src/nix/verify.cc68
1 files changed, 14 insertions, 54 deletions
diff --git a/src/nix/verify.cc b/src/nix/verify.cc
index 9214d3b651d1..39a4395cfe5b 100644
--- a/src/nix/verify.cc
+++ b/src/nix/verify.cc
@@ -10,14 +10,14 @@
 
 using namespace nix;
 
-struct MixVerify : virtual Args
+struct CmdVerify : StorePathsCommand
 {
     bool noContents = false;
     bool noTrust = false;
     Strings substituterUris;
     size_t sigsNeeded;
 
-    MixVerify()
+    CmdVerify()
     {
         mkFlag(0, "no-contents", "do not verify the contents of each store path", &noContents);
         mkFlag(0, "no-trust", "do not verify whether each store path is trusted", &noTrust);
@@ -26,7 +26,17 @@ struct MixVerify : virtual Args
         mkIntFlag('n', "sigs-needed", "require that each path has at least N valid signatures", &sigsNeeded);
     }
 
-    void verifyPaths(ref<Store> store, const Paths & storePaths)
+    std::string name() override
+    {
+        return "verify";
+    }
+
+    std::string description() override
+    {
+        return "verify the integrity of store paths";
+    }
+
+    void run(ref<Store> store, Paths storePaths) override
     {
         restoreAffinity(); // FIXME
 
@@ -158,54 +168,4 @@ struct MixVerify : virtual Args
     }
 };
 
-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>());
+static RegisterCommand r1(make_ref<CmdVerify>());