diff --git a/hosts/common/systemd.nix b/hosts/common/systemd.nix index 35d661df..af872563 100644 --- a/hosts/common/systemd.nix +++ b/hosts/common/systemd.nix @@ -1,13 +1,13 @@ -{ ... }: +{ pkgs, ... }: { systemd.extraConfig = '' # DefaultTimeoutStopSec defaults to 90s, and frequently blocks overall system shutdown. - DefaultTimeoutStopSec=25 + DefaultTimeoutStopSec=20 ''; systemd.user.extraConfig = '' # DefaultTimeoutStopSec defaults to 90s, and frequently blocks overall system shutdown. - DefaultTimeoutStopSec=25 + DefaultTimeoutStopSec=20 ''; services.journald.extraConfig = '' @@ -18,6 +18,41 @@ Compress=no ''; + # decreasing the timeout for the manager itself ("Stop job is running for User Manager for UID 1000"). + # TimeoutStopSec gets stripped from .override file for `user@`, so can't do it that way: + # systemd.services."user@".serviceConfig.TimeoutStopSec = "20s"; + # adding just TimeoutStopSec to `user@1000` causes it to lose all the other fields, including `ExecStart`: + # systemd.services."user@1000".serviceConfig.TimeoutStopSec = "20s"; + # so, just recreate the whole damn service as it appears with `systemd cat 'user@1000'` + # and modify the parts i care about. + systemd.services."user@1000" = { + description = "User Manager for UID %i"; + documentation = [ "man:user@service(5)" ]; + after = [ + "user-runtime-dir@%i.service" + "dbus.service" + "systemd-oomd.service" + ]; + requires = [ "user-runtime-dir@%i.service" ]; + unitConfig.ignoreOnIsolate = true; + + serviceConfig = { + User = "%i"; + PAMName = "systemd-user"; + Type = "notify-reload"; + ExecStart = "${pkgs.systemd}/lib/systemd/systemd --user"; + Slice = "user-%i.slice"; + KillMode = "mixed"; + Delegate = [ "pids" "memory" "cpu" ]; + DelegateSubgroup = "init.scope"; + TasksMax = "infinity"; + TimeoutStopSec = "20s"; #< default: 120s + KeyringMode = "inherit"; + OOMScoreAdjust = 100; + MemoryPressureWatch = "skip"; + }; + }; + # allow ordinary users to `reboot` or `shutdown`. # source: security.polkit.extraConfig = ''