aboutsummaryrefslogtreecommitdiff
path: root/src/nix/optimise-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-16 17:00:24 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-16 20:56:03 +0200
commit23b8b7e096d3a2a784387a09f68115706b1e9552 (patch)
tree5e8756716b67d87b8f8d48dcf5f0f108affe2219 /src/nix/optimise-store.cc
parent40bffe0a43e5f2f320c6bae7e39ea9c26906451d (diff)
nix optimise-store: Add
This replaces "nix-store --optimise". Main difference is that it has a progress indicator.
Diffstat (limited to 'src/nix/optimise-store.cc')
-rw-r--r--src/nix/optimise-store.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/nix/optimise-store.cc b/src/nix/optimise-store.cc
new file mode 100644
index 000000000..725fb75a1
--- /dev/null
+++ b/src/nix/optimise-store.cc
@@ -0,0 +1,41 @@
+#include "command.hh"
+#include "shared.hh"
+#include "store-api.hh"
+
+#include <atomic>
+
+using namespace nix;
+
+struct CmdOptimiseStore : StoreCommand
+{
+ CmdOptimiseStore()
+ {
+ }
+
+ std::string name() override
+ {
+ return "optimise-store";
+ }
+
+ std::string description() override
+ {
+ return "replace identical files in the store by hard links";
+ }
+
+ Examples examples() override
+ {
+ return {
+ Example{
+ "To optimise the Nix store:",
+ "nix optimise-store"
+ },
+ };
+ }
+
+ void run(ref<Store> store) override
+ {
+ store->optimiseStore();
+ }
+};
+
+static RegisterCommand r1(make_ref<CmdOptimiseStore>());