mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 07:31:20 +00:00
systemd: Add an assertion to guarantee oneshot units do not have restart set
This prevents insidious errors once systemd begins handling the unit. If the unit is loaded at boot, any errors of this nature are logged to the console before the journal service is running. This makes it very hard to diagnose the issue. Therefore, this assertion helps guarantee the mistake is not made.
This commit is contained in:
parent
6ff2521974
commit
eda854d50f
|
@ -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 ];
|
||||
|
|
Loading…
Reference in a new issue