nixos-rebuild relies on setting an environment variable to change
behaviour during nixos-rebuild boot/switch between calling update or
install via systemd bootctl. Adding sudo -- as a prefix to various exec
calls does not preserve the environment breaking this mechanism.
This is a some what ugly fix that works.
Closes https://github.com/NixOS/nixpkgs/pull/144429