How to remove a NixOS system profile?

nixos-rebuild boot or nixos-rebuild switch will update /nix/var/nix/profiles/system by default.

But with the -p foobar or --profile-name foobar option, they can be made to update /nix/var/nix/profiles/system-profiles/foobar instead and to create that profile if it doesn’t already exist.

If I’ve done that and want to get rid of one such additional system profile again, what should I do?

Should I simply manually delete it as follows?

sudo rm /nix/var/nix/profiles/system-profiles/foobar{,-*-link}

If so, are additional steps needed or is that all?

Or is there a nixos-* or nix-* command to do system profile removal?

yes

If so, are additional steps needed or is that all?

no. Make sure your current system isn’t linked to it.

Are there plans to add a subcommand to clear these to nix-collect-garbage or derivative? We have --delete-old; a --deleted-named [name/pattern] would be handy.