When doing upgrades (especially large ones) on NixOS with a relatively small root partition, I sometimes run out of space after a bunch of new packages are installed in
error: preallocating file of 716320 bytes: No space left on device
My usual approach has been to run
which frees up space by deleting not only the old generations but also the new packages I'm installing.
The next download attempt will download the new packages all over again, and -- if enough space was freed -- may succeed.
Is there a way to delete only the older derivations?