I don’t have much storage and frequently run out of space during standard rebuilds. I just have a few larger apps that need to be built for one reason or another and sometimes they all need to rebuild at once. My optimized and garbage-collected nix store is only 35GiB or so, not at all an issue for my 256GB SSD, but the storage requirement occasionally balloons past the 80GiB or so I usually have free during those larger updates. To be clear, it is the store and not /tmp that is filling up; nix can easily be pointed to any folder to use as tmp for builds if needed.
Has anybody figured out a way around this sort of issue?
Ideally I’d build on another machine and use that as a binary cache, but I don’t have another computer and won’t for the foreseeable future. I would need to somehow use external storage (it would probably be an SD card I could leave inside). The question is how to make use of that storage for builds. The closest I can think of would be to install a whole other copy of NixOS on external storage, build my configuration, then somehow copy the relevant store entries back to my internal storage, perhaps a VM on the other disk which my host can connect to via the network – not an option, builds would take weeks. Another option would be to permanently put my nix store on an external disk, which is not ideal for obvious reasons, but would work.
That’s pretty large, and it ballooning to 80G seems a bit much. Maybe more incremental updates and cutting down on multi-channel things could also help tame this a bit; 20-50G is way more manageable, and the typical range I’ve seen even with some larger things.
Also, hear me out, chances are migrating to a 500G-1T drive is quite cheap and easy; 256G is ridiculously small for 2025’s SSD prices.
Thank you, I forgot about min-free and max-free, I will definitely set that up. Correct me if I’m wrong though, that will indiscriminately gc to make sure space doesn’t run out, so the build may never finish?
My concern is performance and reliability. My only computer is a 2-in-1 so I would be running my OS off an SD card. Maybe I shouldn’t be concerned with that? It would definitely be slower, and it just seems inherently dodgy.
I don’t know why but often all of my big apps have to rebuilt at once (even if it doesn’t look like they have been updated) so even incremental updates can mean a lot needs to happen in one go. I’ve never actually checked but building things like Firefox or Davinci Resolve can take 10s of GB on their own to build, so I don’t think it’s ridiculous, I just personally use some larger apps that aren’t cached for whatever reason. I am using a Microsoft Surface so I also have to build the kernel. There are definitely little things I can do here and there (like making sure I use the binary cache for Firefox, only installing certain things when I need them) to help but I wanted to explore other options.
I wish I could, on any other device I would.
Occasionally this is what I have needed to do. Also worth saying I only ever have 1 generation available once I have tested the new one.
I think at that point I would just move my /nix to an SD card.
I think what I would ideally want would be to switch between two nix stores and use the external one as a binary cache for the internal one, or something analogous to that. I could rarely gc on the external one meaning upgrades will be quicker, then only pull the derivations I need back onto my internal drive. Having two nix stores is doable, it’s the second part that is the problem.