builders, macs: migrate to fast-nix-gc
Easier to align with our GC targets for hydra-queue-builder and runs much faster, leading to shorter GC durations. At the same time we try to get by with just one GC per hour on Macs to find out if that is sustainable.
Martin Weinelt committed
Jun 27, 2026 at 20:26 UTC
b1c54d63121afdfca7526b20fbcbfa7a487d5685
8 files changed
+76
-23
builders/common/nix.nix
+13
-10
@@ -1,11 +1,16 @@
1
{
2
config,
3
+ inputs,
4
lib,
5
pkgs,
6
...
7
}:
8
9
{
10
+ imports = [
11
+ inputs.fast-nix-gc.nixosModules.default
12
+ ];
13
+
14
nix = {
15
# Backport of NixOS/nix#15992: a temp root registered while a GC is in its
16
# deletion phase was ignored, so hydra-builder's per-build AddTempRoot pins
@@ -14,16 +19,6 @@
19
package = pkgs.nix.appendPatches [ ./nix-gc-addtemproot-race.patch ];
20
nrBuildUsers = config.nix.settings.max-jobs + 32;
21
17
- gc =
18
- let
19
- maxFreed = 800; # GB
20
- in
21
- {
22
- automatic = true;
23
- dates = "hourly";
24
- options = "--max-freed \"$((${toString maxFreed} * 1024**3 - 1024 * $(df --output=avail /nix/store | tail -n 1)))\"";
25
- };
26
-
22
settings = {
23
accept-flake-config = false;
24
builders-use-substitutes = true;
@@ -39,6 +34,14 @@
34
};
35
};
36
37
+ services.fast-nix-gc = {
38
+ enable = true;
39
+ automatic = true;
40
+ dates = "hourly";
41
+ ensureFree = "30%"; # some breathing room for zfs
42
+ keepRecent = "72h";
43
+ };
44
+
45
systemd.services.prune-stale-nix-builds = {
46
description = "Prune stale nix build roots";
47
startAt = "hourly";
flake.lock
+27
@@ -176,6 +176,32 @@
176
"type": "github"
177
}
178
},
179
+ "fast-nix-gc": {
180
+ "inputs": {
181
+ "nix-darwin": [
182
+ "darwin"
183
+ ],
184
+ "nixpkgs": [
185
+ "nixpkgs"
186
+ ],
187
+ "treefmt-nix": [
188
+ "treefmt-nix"
189
+ ]
190
+ },
191
+ "locked": {
192
+ "lastModified": 1782724226,
193
+ "narHash": "sha256-3LUiQ9vfNc9YmgXNC6yO7uvLbL9GUj59f4/vS2unZN4=",
194
+ "owner": "Mic92",
195
+ "repo": "fast-nix-gc",
196
+ "rev": "478b6c87af6f03df7167cdfcb8e4f26cdce15a82",
197
+ "type": "github"
198
+ },
199
+ "original": {
200
+ "owner": "Mic92",
201
+ "repo": "fast-nix-gc",
202
+ "type": "github"
203
+ }
204
+ },
205
"flake-compat": {
206
"flake": false,
207
"locked": {
@@ -772,6 +798,7 @@
798
"colmena": "colmena",
799
"darwin": "darwin_2",
800
"disko": "disko",
801
+ "fast-nix-gc": "fast-nix-gc",
802
"flake-parts": "flake-parts",
803
"flake-utils": "flake-utils",
804
"freescout": "freescout",
flake.nix
+5
@@ -15,6 +15,11 @@
15
ai-robots-txt.url = "https://github.com/ai-robots-txt/ai.robots.txt/raw/refs/heads/main/robots.json";
16
ai-robots-txt.flake = false;
17
18
+ fast-nix-gc.url = "github:Mic92/fast-nix-gc";
19
+ fast-nix-gc.inputs.nixpkgs.follows = "nixpkgs";
20
+ fast-nix-gc.inputs.nix-darwin.follows = "darwin";
21
+ fast-nix-gc.inputs.treefmt-nix.follows = "treefmt-nix";
22
+
23
# This is https://github.com/P3TERX/GeoLite.mmdb
24
# Atlernative https://github.com/sapics/ip-location-db
25
geolite2-asn-mmdb.url = "https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-ASN.mmdb";
macs/common/nix.nix
+16
-13
@@ -1,10 +1,15 @@
1
{
2
config,
3
+ inputs,
4
pkgs,
5
...
6
}:
7
8
{
9
+ imports = [
10
+ inputs.fast-nix-gc.darwinModules.default
11
+ ];
12
+
13
environment.systemPackages = [
14
config.nix.package
15
];
@@ -23,18 +28,16 @@
28
max-silent-time = 7200; # 2h
29
timeout = 43200; # 12h
30
};
26
- gc = {
27
- automatic = true;
28
- interval = [
29
- {
30
- Minute = 15;
31
- }
32
- {
33
- Minute = 45;
34
- }
35
- ];
36
- # ensure up to 100G free space every half hour
37
- options = "--max-freed $(df -k /nix/store | awk 'NR==2 {available=$4; required=100*1024*1024; to_free=required-available; printf \"%.0d\", to_free*1024}')";
38
- };
31
};
32
+
33
+ services.fast-nix-gc = {
34
+ enable = true;
35
+ automatic = true;
36
+ startCalendarInterval = [
37
+ {
38
+ Minute = 15;
39
+ }
40
+ ];
41
+ };
42
+
43
}
macs/profiles/m1.nix
+9
@@ -10,4 +10,13 @@
10
max-jobs = 4;
11
system-features = [ ];
12
};
13
+
14
+ services.fast-nix-gc = {
15
+ ensureFree = "100G"; # per half-hour
16
+ startCalendarInterval = [
17
+ {
18
+ Minute = 45; # second interval
19
+ }
20
+ ];
21
+ };
22
}
macs/profiles/m2.large.nix
+2
@@ -10,4 +10,6 @@
10
max-jobs = 2;
11
system-features = [ "big-parallel" ];
12
};
13
+
14
+ services.fast-nix-gc.ensureFree = "200G"; # per hour
15
}
macs/profiles/ofborg-m1.nix
+2
@@ -9,4 +9,6 @@
9
cores = 2;
10
max-jobs = 4;
11
};
12
+
13
+ services.fast-nix-gc.ensureFree = "100G"; # per hour
14
}
macs/profiles/ofborg-x86_64.nix
+2
@@ -9,4 +9,6 @@
9
cores = 3;
10
max-jobs = 4;
11
};
12
+
13
+ services.fast-nix-gc.ensureFree = "150G"; # per hour
14
}