nixos/systemd: move systemd.watchdog.* to systemd.settings.Manager

This commit is contained in:
Grimmauld 2025-07-20 16:57:49 +02:00
parent 4d3ab0e8d3
commit 493f1339b0
No known key found for this signature in database
2 changed files with 74 additions and 73 deletions

View File

@ -424,6 +424,60 @@ in
'';
type = lib.types.submodule {
freeformType = types.attrsOf unitOption;
options = {
WatchdogDevice = mkOption {
type = types.nullOr types.path;
default = null;
example = "/dev/watchdog";
description = ''
The path to a hardware watchdog device which will be managed by systemd.
If not specified, systemd will default to `/dev/watchdog`.
'';
};
RuntimeWatchdogSec = mkOption {
type = types.nullOr types.str;
default = null;
example = "30s";
description = ''
The amount of time which can elapse before a watchdog hardware device
will automatically reboot the system.
Valid time units include "ms", "s", "min", "h", "d", and "w";
see {manpage}`systemd.time(7)`.
'';
};
RebootWatchdogSec = mkOption {
type = types.nullOr types.str;
default = null;
example = "10m";
description = ''
The amount of time which can elapse after a reboot has been triggered
before a watchdog hardware device will automatically reboot the system.
If left `null`, systemd will use its default of 10 minutes;
see {manpage}`systemd-system.conf(5)`.
Valid time units include "ms", "s", "min", "h", "d", and "w";
see also {manpage}`systemd.time(7)`.
'';
};
KExecWatchdogSec = mkOption {
type = types.nullOr types.str;
default = null;
example = "10m";
description = ''
The amount of time which can elapse when `kexec` is being executed before
a watchdog hardware device will automatically reboot the system. This
option should only be enabled if `reloadTime` is also enabled;
see {manpage}`kexec(8)`.
Valid time units include "ms", "s", "min", "h", "d", and "w";
see also {manpage}`systemd.time(7)`.
'';
};
};
};
example = {
WatchdogDevice = "/dev/watchdog";
@ -471,59 +525,6 @@ in
by other NixOS modules.
'';
};
watchdog.device = mkOption {
type = types.nullOr types.path;
default = null;
example = "/dev/watchdog";
description = ''
The path to a hardware watchdog device which will be managed by systemd.
If not specified, systemd will default to `/dev/watchdog`.
'';
};
watchdog.runtimeTime = mkOption {
type = types.nullOr types.str;
default = null;
example = "30s";
description = ''
The amount of time which can elapse before a watchdog hardware device
will automatically reboot the system.
Valid time units include "ms", "s", "min", "h", "d", and "w";
see {manpage}`systemd.time(7)`.
'';
};
watchdog.rebootTime = mkOption {
type = types.nullOr types.str;
default = null;
example = "10m";
description = ''
The amount of time which can elapse after a reboot has been triggered
before a watchdog hardware device will automatically reboot the system.
If left `null`, systemd will use its default of 10 minutes;
see {manpage}`systemd-system.conf(5)`.
Valid time units include "ms", "s", "min", "h", "d", and "w";
see also {manpage}`systemd.time(7)`.
'';
};
watchdog.kexecTime = mkOption {
type = types.nullOr types.str;
default = null;
example = "10m";
description = ''
The amount of time which can elapse when `kexec` is being executed before
a watchdog hardware device will automatically reboot the system. This
option should only be enabled if `reloadTime` is also enabled;
see {manpage}`kexec(8)`.
Valid time units include "ms", "s", "min", "h", "d", and "w";
see also {manpage}`systemd.time(7)`.
'';
};
};
###### implementation
@ -659,19 +660,6 @@ in
DefaultIPAccounting=yes
''}
DefaultLimitCORE=infinity
${optionalString (cfg.watchdog.device != null) ''
WatchdogDevice=${cfg.watchdog.device}
''}
${optionalString (cfg.watchdog.runtimeTime != null) ''
RuntimeWatchdogSec=${cfg.watchdog.runtimeTime}
''}
${optionalString (cfg.watchdog.rebootTime != null) ''
RebootWatchdogSec=${cfg.watchdog.rebootTime}
''}
${optionalString (cfg.watchdog.kexecTime != null) ''
KExecWatchdogSec=${cfg.watchdog.kexecTime}
''}
${attrsToSection cfg.settings.Manager}
'';
@ -871,5 +859,21 @@ in
NixOS does not officially support this configuration and might cause your system to be unbootable in future versions. You are on your own.
'')
(mkRemovedOptionModule [ "systemd" "extraConfig" ] "Use systemd.settings.Manager instead.")
(lib.mkRenamedOptionModule
[ "systemd" "watchdog" "device" ]
[ "systemd" "settings" "Manager" "WatchdogDevice" ]
)
(lib.mkRenamedOptionModule
[ "systemd" "watchdog" "runtimeTime" ]
[ "systemd" "settings" "Manager" "RuntimeWatchdogSec" ]
)
(lib.mkRenamedOptionModule
[ "systemd" "watchdog" "rebootTime" ]
[ "systemd" "settings" "Manager" "RebootWatchdogSec" ]
)
(lib.mkRenamedOptionModule
[ "systemd" "watchdog" "kexecTime" ]
[ "systemd" "settings" "Manager" "KExecWatchdogSec" ]
)
];
}

View File

@ -29,6 +29,10 @@
systemd.settings.Manager = {
DefaultEnvironment = "XXX_SYSTEM=foo";
WatchdogDevice = "/dev/watchdog";
RuntimeWatchdogSec = "30s";
RebootWatchdogSec = "10min";
KExecWatchdogSec = "5min";
};
systemd.user.extraConfig = "DefaultEnvironment=\"XXX_USER=bar\"";
services.journald.extraConfig = "Storage=volatile";
@ -88,13 +92,6 @@
'';
};
systemd.watchdog = {
device = "/dev/watchdog";
runtimeTime = "30s";
rebootTime = "10min";
kexecTime = "5min";
};
environment.etc."systemd/system-preset/10-testservice.preset".text = ''
disable ${config.systemd.services.testservice1.name}
'';