aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/globals.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-05 20:43:42 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-05 20:43:42 +0200
commit0b606aad46e1d96da36d4831df63ad90f11d21c3 (patch)
tree5787f4f043f7316a8ad4625772abe9a4da3c1d57 /src/libstore/globals.hh
parentb932ea58ec610830ed3141bb14fbd812aa66b2c1 (diff)
Add automatic garbage collection
Nix can now automatically run the garbage collector during builds or while adding paths to the store. The option "min-free = <bytes>" specifies that Nix should run the garbage collector whenever free space in the Nix store drops below <bytes>. It will then delete garbage until "max-free" bytes are available. Garbage collection during builds is asynchronous; running builds are not paused and new builds are not blocked. However, there also is a synchronous GC run prior to the first build/substitution. Currently, no old GC roots are deleted (as in "nix-collect-garbage -d").
Diffstat (limited to 'src/libstore/globals.hh')
-rw-r--r--src/libstore/globals.hh10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index c20d147f5..41d332311 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -4,8 +4,9 @@
#include "config.hh"
#include <map>
-#include <sys/types.h>
+#include <limits>
+#include <sys/types.h>
namespace nix {
@@ -342,6 +343,13 @@ public:
Setting<Strings> hashedMirrors{this, {"http://tarballs.nixos.org/"}, "hashed-mirrors",
"A list of servers used by builtins.fetchurl to fetch files by hash."};
+
+ Setting<uint64_t> minFree{this, 0, "min-free",
+ "Automatically run the garbage collector when free disk space drops below the specified amount."};
+
+ Setting<uint64_t> maxFree{this, std::numeric_limits<uint64_t>::max(), "max-free",
+ "Stop deleting garbage when free disk space is above the specified amount."};
+
};