Auto-optimize nix stores on dev and staging VMs
NixOS likes to keep stuff around and is filling up our staging VMs' hard drives.
The NixOS Wiki recommends turning on nix-store auto optimization which turns identical files into hard links when installing new software (basically a user space de-dup).
This defaulted to true for a while, but was later made default to false since it can cause slowness for some nix operations in systems with lots of software and/or many generations (more than 1M, some say more than 10M links in /nix/store/.links
).
After running the optimization step manually, the staging monitoring machine currently has 185.665 links in that directory, leaving us with a safety margin I would deem comforting enough to try this out.
I ran the optimization step on our staging grid to get us out of the >80% disk usage danger zone:
[flo@monitoring:~]$ nix-store --optimise
2987.75 MiB freed by hard-linking 166247 files
[flo@la:~]$ ssh flo@storage001.privatestorage-staging.com "nix-store --optimise"
2579.92 MiB freed by hard-linking 236263 files
[flo@la:~]$ ssh flo@payments.privatestorage-staging.com "nix-store --optimise"
3036.69 MiB freed by hard-linking 245178 files
Resulting in: