lol

Merge pull request #266369 from SuperSandro2000/systemd-unit-empty-lines

systemd-lib: cleanup empty lines in unit files

authored by

Will Fancher and committed by
GitHub
c20ad5d3 1f37660f

+17 -18
+17 -18
nixos/lib/systemd-lib.nix
··· 376 376 377 377 serviceToUnit = name: def: 378 378 { inherit (def) aliases wantedBy requiredBy enable overrideStrategy; 379 - text = commonUnitText def + 380 - '' 381 - [Service] 382 - ${let env = cfg.globalEnvironment // def.environment; 383 - in concatMapStrings (n: 384 - let s = optionalString (env.${n} != null) 385 - "Environment=${builtins.toJSON "${n}=${env.${n}}"}\n"; 386 - # systemd max line length is now 1MiB 387 - # https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af 388 - 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)} 389 - ${if def ? reloadIfChanged && def.reloadIfChanged then '' 390 - X-ReloadIfChanged=true 391 - '' else if (def ? restartIfChanged && !def.restartIfChanged) then '' 392 - X-RestartIfChanged=false 393 - '' else ""} 394 - ${optionalString (def ? stopIfChanged && !def.stopIfChanged) "X-StopIfChanged=false"} 395 - ${attrsToSection def.serviceConfig} 396 - ''; 379 + text = commonUnitText def + '' 380 + [Service] 381 + '' + (let env = cfg.globalEnvironment // def.environment; 382 + in concatMapStrings (n: 383 + let s = optionalString (env.${n} != null) 384 + "Environment=${builtins.toJSON "${n}=${env.${n}}"}\n"; 385 + # systemd max line length is now 1MiB 386 + # https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af 387 + 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)) 388 + + (if def ? reloadIfChanged && def.reloadIfChanged then '' 389 + X-ReloadIfChanged=true 390 + '' else if (def ? restartIfChanged && !def.restartIfChanged) then '' 391 + X-RestartIfChanged=false 392 + '' else "") 393 + + optionalString (def ? stopIfChanged && !def.stopIfChanged) '' 394 + X-StopIfChanged=false 395 + '' + attrsToSection def.serviceConfig; 397 396 }; 398 397 399 398 socketToUnit = name: def: