Shrinking NixOS Ram footprint and resource requirements to the bare minimum
19 points by msangi
19 points by msangi
This looks like it could be very useful to apply to a cheap, low-spec VPS that only acts as a relay for an overlay network. My VPS's primary purpose is to run a Nebula lighthouse that connects my other devices together, and I use it for some other things because it has spare resources.
If you're low on resources I would also look into doing builds on a beefy machine and push only the built system to the VPS.
One option is the standard nixos-rebuild switch on a powerful machine passing the --target-host parameter. I've done it successfully in the past.
Another option is to go fully appliance style. The series of posts starting with https://nixcademy.com/posts/auto-growing-nixos-appliance-images-with-systemd-repart/ covers it. I haven't tried it before but it looks neat.
Yeah, after a few bad OOM experiences I've started using --build-host from the VPS back to my desktop.
Note one can even do that when using a Mac. Either now use Determinate Nix with its Linux builder, or, like I did for a while, with a NixOS machine within OrbStack, which I already used for containers. I just ran orb nixos-rebuild --target-host foo on my MacBook.
It’s a pretty niche use case, but I wish there was a lighter version of NixOS for this sort of thing. Having a fully declarative OS you can rebuild trivially is so enticing, but, for me, it’s not worth having to quadruple my cheap hobby VPS RAM (from 128 -> 512 or more). smolBSD is close, but is more like a non-updatable appliance, which has even worse downsides, for my purposes.
512MB is to rebuild, not to run, so if you built from another machine you might be able to get away with 128MB if the idle usage is 96MB. finix or sixos could also be an option if the init system is taking up a lot of it.
Yes, good point, thanks. The previous best I'd seen didn't fit into 256 MB, even when idle. I will have to play with this config and see how it goes!