logoalt Hacker News

Shrinking NixOS RAM footprint and resource requirements to the bare minimum

106 points • by birdculture • last Sunday at 2:52 PM • 14 comments • view on HN

Comments

KingMachiavelli • today at 6:04 AM

I really wish building minimal, custom kernels was easier. NixOS makes it somewhat sane but it's still a mess of custom kconfig, defconfig target hacking, and manually splicing out the necessary firmware and kernel modules. The kernel doesn't even have an interface to show what firmware blobs have been loaded. You can do some firmware signature enforcement but I guess no one cares about random binary blobs are running just to work your laptop webcam.

It would be very useful if I could just boot a kernel and get an instant report of what kernel config, firmware and modules are actually used/needed. You can kind of do this but

attilaolah • today at 2:35 PM

I was running a similar experiment but on bare metal, and my bottleneck was disk not RAM, so trimming the firmware and modules yield the biggest win. And I compile on a different host and just push binaries to the resulting systems.

One thing I was wondering is, whether switching some leaf packages to Musk would help. Rebuilding the whole system for Musl seems broken most of the time, but many leaf packages can still be cross-compiled. So e.g. I'd get a Caddy or OpenBao binaries, etc.

wrxd • today at 7:53 AM

Tangential but TierHive looks to be doing great work. You can get a VPS from them for about a couple of dollars a year.

It's not going to be powerful (128MB of RAM 1GB of storage) but if you run Alpine or NetBSD you can use it as a WireGuard peer, to host a small Website or to run some cron jobs.

➕ show 1 reply
yjftsjthsd-h • today at 6:05 AM

> Blacklisted the hardware a KVM guest never has or doesn't need

I'm a little surprised that matters; shouldn't Linux be lazy loading drivers only when it sees hardware?

➕ show 2 replies
viraptor • today at 9:19 AM

This reminded me I wanted to check how small can I make chrome by disabling all the unnecessary features. I'd really like to get something I can swap in the electron packages to reduce the ram usage. Sometimes it's worth fighting for the resources we pay for.

➕ show 1 reply
ximm • today at 7:19 AM

I expected a discussion of NixOS specific issues like different versions of libraries that are loaded at the same time. Instead, this article disucces kernel tweaks and disabling system services, which is not specific to NixOS. So the title is a bit misleading.

➕ show 1 reply
johndxy • last Sunday at 5:39 PM

[flagged]