Seeking advise about running "nixos-rebuild" and small storage space

After installing a fresh install of NixOS onto a 128GB SSD, I’ve been able to run my initial config by running sudo nixos-rebuild switch –upgrade . I have a lot of software, but after installation, it occupies roughly 71.85GBs of 128GBs.

However, when I run the same command, I’m unable to upgrade any of the software due to running out of space.

I’ve ran nix-env , and deleted all generations but one, and deleted all excess stuff, by the following command: sudo nix-env --delete-generations -p /nix/var/nix/profiles/system +1 && sudo nix-store --gc --print-roots && sudo nix-store --optimise && sudo nix-collect-garbage --delete-older-than 2d .

Any advise on how I can build and upgrade my packages in such a limited space/? Is there a flag I can use that would allow certain packages to be updated and have older generation of software deleted as the updates happen in real time?

Would I have to expand my root to another drive and partition?

1 Like

How much storage is the nix store occupying, and how large is the actual system closure?

$ df -sh /nix/store
113G    /nix/store/
$ nix path-info -Sh /run/current-system
/nix/store/14qhlwdvymcd53l5f3l0zv3gq9ncgq6r-nixos-system-mimas-26.05.20260324.46db2e0     16.9 GiB

The block above shows commands that can retrieve the information, together with an example output.

Also, I assume, you have the store directly on the root, so how huge is the root partition and how much of space is occupied? How large is your ESP? Last but not least, when you rebuild and get your space problems, what is the exact error?

1 Like