1
0
Fork 1
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:
William A. Kennington III 2014-04-09 23:55:17 -05:00 committed by Eelco Dolstra
parent 6ff2521974
commit eda854d50f

View file

@ -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 ];