systemd-lib: cleanup empty lines in unit files

This commit is contained in:
Sandro Jäckel 2023-11-09 01:58:23 +01:00
parent 891e7b46b9
commit ae0bbc00e8
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5

View File

@ -376,24 +376,23 @@ in rec {
serviceToUnit = name: def: serviceToUnit = name: def:
{ inherit (def) aliases wantedBy requiredBy enable overrideStrategy; { inherit (def) aliases wantedBy requiredBy enable overrideStrategy;
text = commonUnitText def + text = commonUnitText def + ''
'' [Service]
[Service] '' + (let env = cfg.globalEnvironment // def.environment;
${let env = cfg.globalEnvironment // def.environment; in concatMapStrings (n:
in concatMapStrings (n: let s = optionalString (env.${n} != null)
let s = optionalString (env.${n} != null) "Environment=${builtins.toJSON "${n}=${env.${n}}"}\n";
"Environment=${builtins.toJSON "${n}=${env.${n}}"}\n"; # systemd max line length is now 1MiB
# systemd max line length is now 1MiB # https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af
# https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af in if stringLength s >= 1048576 then throw "The value of the environment variable ${n} in systemd service ${name}.service is too long." else s) (attrNames env))
in if stringLength s >= 1048576 then throw "The value of the environment variable ${n} in systemd service ${name}.service is too long." else s) (attrNames env)} + (if def ? reloadIfChanged && def.reloadIfChanged then ''
${if def ? reloadIfChanged && def.reloadIfChanged then '' X-ReloadIfChanged=true
X-ReloadIfChanged=true '' else if (def ? restartIfChanged && !def.restartIfChanged) then ''
'' else if (def ? restartIfChanged && !def.restartIfChanged) then '' X-RestartIfChanged=false
X-RestartIfChanged=false '' else "")
'' else ""} + optionalString (def ? stopIfChanged && !def.stopIfChanged) ''
${optionalString (def ? stopIfChanged && !def.stopIfChanged) "X-StopIfChanged=false"} X-StopIfChanged=false
${attrsToSection def.serviceConfig} '' + attrsToSection def.serviceConfig;
'';
}; };
socketToUnit = name: def: socketToUnit = name: def: