From 6da7835ad9f49820180684fd2edf7fb811c51db0 Mon Sep 17 00:00:00 2001 From: atlas Date: Fri, 10 Jul 2026 02:46:25 +0200 Subject: [PATCH] =?UTF-8?q?fix(#2264):=20boot.tmp.useTmpfs=20=3D=20false?= =?UTF-8?q?=20=E2=80=94=20disk-backed=20/tmp=20for=20agents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent containers currently mount /tmp as a 3.2 GB tmpfs (RAM-backed). Large scratch writes (nix-develop shells, cargo build dirs) eat container RAM unnecessarily and can exhaust the tmpfs, losing in-flight work. Set boot.tmp.useTmpfs = false so /tmp is disk-backed instead. boot.tmp.cleanOnBoot (default true) preserves the ephemeral-per-boot semantics — /tmp is cleared on container start, same as before. Closes #2264. Supersedes PR #2299 (TMPDIR redirect + state/tmp). --- nix/templates/harness-base.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nix/templates/harness-base.nix b/nix/templates/harness-base.nix index fe12bb4c..437d7440 100644 --- a/nix/templates/harness-base.nix +++ b/nix/templates/harness-base.nix @@ -1442,6 +1442,19 @@ in boot.isNspawnContainer = true; + # Use a disk-backed /tmp instead of the default tmpfs so large scratch + # writes (nix-develop shells, cargo build dirs, multi-GB downloads) land + # on disk rather than eating container RAM. The tmpfs default mounts + # ~3.2 GB of RAM per container; disk-backed /tmp is effectively unlimited + # and cheaper for agents that do heavy build work. + # + # cleanOnBoot defaults to false in nixpkgs — set it explicitly so /tmp is + # cleared on each container start (D! tmpfiles rule), preserving the same + # ephemeral-per-boot semantics agents already expect from the old tmpfs, + # just without the RAM cost. + boot.tmp.useTmpfs = false; + boot.tmp.cleanOnBoot = true; + # Every agent gets flakes + the modern `nix` CLI out of the box. # Equivalent to passing `--extra-experimental-features 'nix-command # flakes'` on every invocation. Agents shell out to `nix build` /