serokell / deploy-rs

A simple multi-profile Nix-flake deploy tool.
Other
1.42k stars 101 forks source link

`$TMPDIR` env var not entirely respected in local builds #283

Open jficz opened 4 months ago

jficz commented 4 months ago

I effectively cannot build any configuration when the build machine has /tmp mounted on a partition (or tmpfs in my case) when there isn't enough space for the build (which is a rather common occurrence lately). Same as with remote builds when the target machine is limited similarly.

The workaround for nixos-rebuild is to set $TMPDIR to somewhere with enough capacity for the build but this is not entirely respected by deploy as a part of the build does happen in whatever TMPDIR is set to but the "big" build still happens in /tmp either locally or on the remote machine, depending on remoteBuild.

Example error for a local build, TMPDIR set to /tmp2:

🚀 ℹ️ [deploy] [INFO] Building profile `system` for node `muffy`
error:
       … writing file '/tmp/nix-build-etc-alsa-conf.d-49-pipewire-modules.conf.drv-0/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90'

       error: writing to file: No space left on device
🚀 ❌ [deploy] [ERROR] Failed to push profile: Nix build command resulted in a bad exit code: Some(1)

For local builds, TMPDIR should imho be respected in all build phases. For remote builds see #282.

The only workaround that works for me (tm) is to remount /tmp to some place with enough capacity for the duration of the build, which is ... not optimal.