Set nicety of nixos-upgrade.service

I have set some nice and IO scheduling settings on my nix-gc.service and nix-optimise.service and they work great. Now I also want to use such settings for the nixos-upgrade.service but they are obviously only affecting the nixos-rebuild command and the evaluation phase. The build phase happens in the nix daemon which lives in nix-daemon.service and is unaffected by this.

Here is what I am currently doing:

let
  low-prio = {
    Nice = 19;
    IOSchedulingClass = "idle";
    IOSchedulingPriority = 7;
  };
in
{
  nix.gc.automatic = true;
  nix.optimise.automatic = true;
  system.autoUpgrade.enable = true;
  systemd.services.nix-gc.serviceConfig = low-prio;
  systemd.services.nix-optimise.serviceConfig = low-prio;
  systemd.services.nixos-upgrade.serviceConfig = low-prio;
}

Is it possible to change the nicety of the build phase for a single nix command? Or is it advisable to just force the whole nix-daemon.service to this “low-prio” settings? What adverse effects might I expect (aside from builds taking longer)?

I have a similar config. I had assumed that because the nixos-upgrade service runs as root, it does not go via the daemon. Now I want to be sure.

@uep I think that depends how you install nix, in single user mode or multi user mode (i.e. with daemon). I do not know if you can have anything but daemon mode in NixOS.

On NixOS I have observed that all builds are done by the daemon, be it nix build, nix-build, nixos-rebuild or sudo ....