How much storage does NixOS need?

Hi! I’m using HP Pavillion Gaming 15 laptop with 256Gb SSD. I have installed NixOS 20.03 to this drive and gave it 25Gb as I always did with Debian before. /home is the other partition so I had 25Gb for system only. But after 3 month of great experience it turns out that I can’t nixos-rebuild switch because I have not enough space. I did nix-collect-garbage -d and nix-store --optimize. / is using 80% of storage for now and can’t rebuild.

After googling the topic I concluded that there is no way to widen /nix/store space by mounting another partition somehow. Also I don’t want to use another computer to build my system. So I decided to reinstall NixOS properly this time.

The question is how much storage should I give to the system? I mean how large can system grow during the rebuild? From big software I use only Plasma, Firefox, VSCode and LibreOffice. But what if I decide to install CLion? What amount of storage can make me sure it’s enough to rebuild pure system?

Is it relevant to separate /home when you have only 256Gb of space with NixOS?

I just bought a terabyte hard drive just for nix so I can basically ignore this problem.

Do you use home manager? Be sure to delete it’s generations as well. Same goes for lorri, direnv persistent shell, or anything else that creates gc roots.

also check /nix/var/nix/gcroots to see what is still being referenced, and preventing cleanup

Please have a look at

and use

## hope you're using bash
zGenerationsInDaysToBeDeleted=22 ## my individual preference of having the 22 days available; adjust to your personal needs
nix-collect-garbage -d --delete-older-than ${zGenerationsInDaysToBeDeleted}

Personally I have a store size of 20 GiB, this were it is stable over the course of the last month’s.

Additionally I use ZFS and have a separate subvolume for the store that has compression enabled, which currently saves about 50%.

Also I enabled auto optimisation to reduce amount of data written to my SSD.

Last but not least, having gaming in the name and then putting just 256GiB SSD feels like a joke…


Semi-related question: Can’t we have a service which auto-collects garbage?

I mean, we can set up a threshold as days (or better, keep last N) and remove generations + run nix-collect-garbage every 2 days or so with a systemd timer.

Does it ever removes something which an active generation needs? Or are there more things to consider?

Isn’t that what nix.gc.automatic does? There are options to configure it under nix.gc.*.


Good point, I must check the available options better :grimacing: Thanks

To answer the OP’s original question:

$ du -hsc /nix/store
182G    /nix/store
$ ls /nix/var/nix/profiles/system*link | wc -l
1 Like

Shouldn’t the real answer be “it depends”? As it is for every other distribution as well?

Of course, nix is a bit more hungry for disk space, but it also brings tools like garbage collection and store optimisation to mitigate.

Also a huge difference compared to other systems, nixOS has all those different versions of language compilers in the store. It’s not that they get installed and managed by some third party tool within the users home.

So, if one does do much, store consumption will be much higher than for those who just want their WM and VLC to watch a video here and there.

1 Like

I never separated /home in any OS.

The only time i use a different partition is when using UEFI. Then i have /boot on a FAT32 partition. Or separate /boot when encrypting /.

Else i have the whole disk as /.

With just 256 GB you will have to do garbage collection more often then with 512 GB.

Doesn’t the newer version of Nix has a feature for that?

I never did as well, for “classic” filesystems, though with BTRFS (back on Arch) and ZFS (now on nixOS) I really like to have each subfolder of /home as its own subvolume for more granular snapshotting, as well as having the store in its own volume, to have it compressed.

Not to speak about the quota assigned to my sons $HOME to avoid him spilling my precious diskspace :smiley: