Shrinking NixOS Ram footprint and resource requirements to the bare minimum

19 points by msangi 19 hours ago on lobsters | 7 comments

jaculabilis | 15 hours ago

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.

[OP] msangi | 14 hours ago

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.

jaculabilis | 13 hours ago

Yeah, after a few bad OOM experiences I've started using --build-host from the VPS back to my desktop.

diktomat | an hour ago

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.

jaredkrinke | 12 hours ago

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.

jaculabilis | 11 hours ago

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.

jaredkrinke | 10 hours ago

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!

tuxes | 3 hours ago

Comment removed by its author