diff options
| author | Lily Ballard <lilyball@apple.com> | 2023-10-09 16:08:01 -0700 |
|---|---|---|
| committer | Lily Ballard <lilyball@apple.com> | 2023-10-09 16:09:11 -0700 |
| commit | 160eb3d99de1dd8e4d0542ab02a6831aa31c7204 (patch) | |
| tree | a5dcaa821df8c3189030da5b289e0408a3c0d58d /modules | |
| parent | 8b6ea26d5d2e8359d06278364f41fbc4b903b28a (diff) | |
linux-builder: avoid /tmp for certs
Fixes #768
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/nix/linux-builder.nix | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index 0d473d3..402b3b5 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -10,6 +10,18 @@ let builderWithOverrides = cfg.package.override { inherit (cfg) modules; }; + + # create-builder uses TMPDIR to share files with the builder, notably certs. + # macOS will clean up files in /tmp automatically that haven't been accessed in 3+ days. + # If we let it use /tmp, leaving the computer asleep for 3 days makes the certs vanish. + # So we'll use /run/org.nixos.linux-builder instead and clean it up ourselves. + script = pkgs.writeShellScript "linux-builder-start" '' + export TMPDIR=/run/org.nixos.linux-builder USE_TMPDIR=1 + rm -rf $TMPDIR + mkdir -p $TMPDIR + trap "rm -rf $TMPDIR" EXIT + ${builderWithOverrides}/bin/create-builder + ''; in { @@ -75,7 +87,7 @@ in serviceConfig = { ProgramArguments = [ "/bin/sh" "-c" - "/bin/wait4path /nix/store && exec ${builderWithOverrides}/bin/create-builder" + "/bin/wait4path /nix/store && exec ${script}" ]; KeepAlive = true; RunAtLoad = true; |
