How to delete the single only last old generations in `test` profile

I have used nixos-rebuild boot --flake ./myflake#desktop -p "test" which resulted in a new boot entry
now I erased all generations with
nix-env --delete-generations --profile /nix/var/nix/profiles/system-profiles/test
which deleted all but left the last one.

How can I delete all generations and then also remove the boot entry from Grub?

I am not sure I quite understand correctly. --delete-generations leaves the current generation alive, hopefully. Your system must run on something I guess. So you cannot really delete all generations.

As for the boot loader, you can reinstall that.

But sudo nixos-rebuild --install-bootloader switch --flake ./myflake#desktop -p "test" should do that usually.

Not sure if this is the best way, but I do it sometimes.


Edit: I just checked, apparently

sudo nix-collect-garbage -d
sudo nixos-rebuild boot

should also do the trick.

Actually the test profile is a separate profile and also represented in the boot loader.
This corresponds not with the normal system profile (?) and I should be able to delete it.

oh yes, now I start to understand. But I don’t use that feature. Maybe someone else knows more than me about this.

I think deleting the /nix/var/nix/profiles/system-profiles/test symlink is enough. Such that the garbage collector
removes the stuff. Not quite sure.