From 0b606aad46e1d96da36d4831df63ad90f11d21c3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Sep 2017 20:43:42 +0200 Subject: 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 = " specifies that Nix should run the garbage collector whenever free space in the Nix store drops below . 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"). --- src/libstore/globals.hh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/libstore/globals.hh') diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index c20d147f5d34..41d3323117b4 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -4,8 +4,9 @@ #include "config.hh" #include -#include +#include +#include namespace nix { @@ -342,6 +343,13 @@ public: Setting hashedMirrors{this, {"http://tarballs.nixos.org/"}, "hashed-mirrors", "A list of servers used by builtins.fetchurl to fetch files by hash."}; + + Setting minFree{this, 0, "min-free", + "Automatically run the garbage collector when free disk space drops below the specified amount."}; + + Setting maxFree{this, std::numeric_limits::max(), "max-free", + "Stop deleting garbage when free disk space is above the specified amount."}; + }; -- cgit 1.4.1