Overriding options in systemd units generated by NixOS

I am on NixOS and some parts of my configuration generate systemd units, for example nix.gc.automatic=true; generates nix-gc.service.

Is there any way to add something to that service? I would like to override the nice and io scheduling of this service.

Another case where I encountered this problem is with system.autoUpgrade.enable=true; as part of my nixos configuration is encrypted with git-crypt but that program is not avaiable in the nixos-upgrade.service.

1 Like

Those generated units are no different than any other units. If you know their name you can modify them.

systemd.services.nixos-upgrade.path = [ pkgs.git-crypt ];
2 Likes

Quoting shimun via NixOS Discourse (2021-06-22 19:55:46)

Those generated units are no different than any other units. If you know
their name you can modify them.

systemd.services.nixos-upgrade.path = [ pkgs.git-crypt ];

Wow that was easy!

1 Like