Normally you can just run
sudo nixos-rebuild switch which will replace your
grub.cfg with only the live system profiles. The live system profiles are the symlinks
/nix/var/nix/profiles. However, this does not work if you do not have a
configuration.nix on your NixOS box like with many server deployments.
In that case you can run, as root,
nix-env --delete-generations old --profile /nix/var/nix/profiles/system followed by
nix-env --delete-generations old --profile /nix/var/nix/profiles/system will remove all but the newest system garbage collection roots and
/nix/var/nix/profiles/system/bin/switch-to-configuration switch will reload the system configuration you are already on and update
grub.cfg with only the live system profiles. Thus your
grub.cfg will only have one entry in it and you have not had to change your system configuration. If you want to then garbage collect the old profiles you can run
nix-store --gc .