How can I completely remove old nixos-generations?
I know that I can delete old generations with nix-collect-garbage
or even nix-collect-garbage -d
. But this seems not to work correctly for system generations.
So: How can I really list and remove old NixOS-system generations?
Details:
-
nix-collect-garbage -d
was run (as root) -
nix-env -p /nix/var/nix/profiles/system --list-generations
lists exactly 1 configuration -
/boot/grub/grub.cfg
contains exactly 1 configuration (“NixOS - Default”) - but
/nix/store
contains e.g. several old linux-kernels, gcc etc.
Checking the reverse-dependencies of the old linux-kernels returns e.g.:
# nix-store --query --referrers /nix/store/0n0j02amv1vayml7qr7nlrl8rzrycgyf-linux-4.19.69
/nix/store/0n0j02amv1vayml7qr7nlrl8rzrycgyf-linux-4.19.63
/nix/store/ygcr4jynnr4cp1y0dxs1s8chx1x9k900-kernel-modules
/nix/store/aymqf7y6swzrnm0c467ghklcgk8b9ajz-nixos-system-MYHOST-19.03.173228.93ea6db29cc
# nix-store --query --referrers /nix/store/832wnm2846j4avwicy1n7sar6yaijvnr-linux-4.19.69
/nix/store/832wnm2846j4avwicy1n7sar6yaijvnr-linux-4.19.69
/nix/store/z81yd4pg3biy8zw8c675fa3qzycq1s0v-kernel-modules
/nix/store/100y8581l6qffgl9x8ligwm6k6731941-nixos-system-MYHOST-19.03.173408.bd6ba87381e
# nix-store --query --referrers f38dx1144qc28hk1ji10f4klgmq4rp3f-linux-4.19.87
/nix/store/f38dx1144qc28hk1ji10f4klgmq4rp3f-linux-4.19.87
/nix/store/yimd00zkkf2wpkybfcz7iax3xr0m9s7f-kernel-modules
/nix/store/4fw2cigw4680cq6jh1g4xj11905579pz-nixos-system-MYHOST-19.09.1529.808d3c6d123
So, it seems that there are still some old nixos-system-generations, but they are not included in the list of generations and are not deleted from the garbage-collector.
How can I list and delete them?