Back to my Roots
· 2 min read · November 05, 2025 · #nixos #techThis is another one of those that’s largely documenting something for myself, but I’m sharing it in case others find it useful. And because self-aggrandisement is what it’s all about these days amirite?
I recently had issues because my NixOS installation ran out of space in the root partition wherein lies /nix/store/, the read-only filesystem containing the Nix store. It’s a pain when this runs out of space because then upgrading gets tricky—due to rollback support, there’s a general tendency to need enough space for at least all the new stuff in the new version in addition to the old versions.
I’d done all the usual garbage collection to try to free up as much space as possible—but still not enough free. What to do? This had used to work so I figured it was probably something to do with some content that should be being garbage collected but wasn’t—I’ve had that problem before when playing around with flakes. Some searching around showed that the solution was actually relatively straightforward.
First, find the roots – these are linked in /nix/var/nix/gcroots – then resolve them and use nix path-info --closure-size to list all the closures with their real sizes. Something like:
#!/usr/bin/env bash
for; do
res="
"
done
|
This gave me the following (line numbers added after the fact):
1
2
3
4
5
6
7
8
9
10
The first three lines under /nix/var/nix/profiles are small and channel-state related; the fourth is also tiny and something flake-related. Lines 8 and 9 beginning /run/ are the currently running system so leave them alone; the match of the underlying path with that of line 7 shows that 931 is the currently running generation.
However, lines 5 and 6 are suspicious:
5
6
These look like dead roots from random rebuilds, tryouts, whatever. And the first one is big at over 14GiB. So just delete it and re-run garbage collection:
&&
Lo and behold! suddenly I have about 15GiB extra free. Happy days :)
In the end, I tweaked that script to the following (logically) one-liner; recorded here so I can copy’n’paste it again in future:
| | while ; do
&&
done | | | | | |