diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 7d528348918..4705ceb8086 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -630,6 +630,12 @@ in config = { + assertions = mapAttrsToList (name: service: { + assertion = !hasAttr "Type" service.serviceConfig || service.serviceConfig.Type != "oneshot" + || !hasAttr "Restart" service.serviceConfig || service.serviceConfig.Restart == "no"; + message = "${name}: Type=oneshot services must have Restart=no"; + }) cfg.services; + system.build.units = units; environment.systemPackages = [ systemd ];