But I was really after an example how to remove any package. I’m not saying that I should remove sudo, perl, strace, rsync… But if I really wanted… How to do it?
You can use nixos-option command to view which modules define environment.systemPackages option, and then look into their source code to find out how to disable them. Or just grep the nixos/ directory in the Nixpkgs repo for the packages you want to remove to find those modules.
So it is OK to add packages into environment.systemPackages list but to remove it, I should rather disable module that added the package in the first place.