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.
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.