One minute
Delete old Generations in NixOS
I’m really enjoying my dabblings with NixOS, but it’s a pain to find information about lots of things. One of these examples is how to delete old generations to free up some hard drive real estate. Since it took me a while to find a workflow that didn’t involve manually deleting symlinks I thought I might as well post what I did here for your (and my) future reference.
So first to delete old generations you can run sudo nix-collect-garbage --delete-older-than <x>d
where <x>
is any number of days. So for 2 it would delete any generation older that 2 days, for example.
Running that command frees up the disk space but does not itself delete boot entries for these old generations. To do that you need to also run a rebuild-switch using sudo nixos-rebuild switch
or whatever you use to build your system. Since I’m using flakes the command I’m running is sudo nixos-rebuild switch --flake .#nic-desktop
.
When that’s done you should have some space freed up and also less generations clogging up your boot loader.
Thanks for reading ❄️