nixos/logind: migrate to settings option
This commit is contained in:
@@ -202,6 +202,8 @@
|
|||||||
- `systemd.watchdog.kexecTime` was renamed to `systemd.settings.Manager.KExecWatchdogSec`
|
- `systemd.watchdog.kexecTime` was renamed to `systemd.settings.Manager.KExecWatchdogSec`
|
||||||
- `systemd.enableCgroupAccounting` was removed. Cgroup accounting now needs to be disabled directly using `systemd.settings.Manager.*Accounting`.
|
- `systemd.enableCgroupAccounting` was removed. Cgroup accounting now needs to be disabled directly using `systemd.settings.Manager.*Accounting`.
|
||||||
|
|
||||||
|
- `services.logind.extraConfig` was converted to RFC42-style `services.logind.settings.Login`.
|
||||||
|
|
||||||
- `services.ntpd-rs` now performs configuration validation.
|
- `services.ntpd-rs` now performs configuration validation.
|
||||||
|
|
||||||
- Immich now has support for [VectorChord](https://github.com/tensorchord/VectorChord) when using the PostgreSQL configuration provided by `services.immich.database.enable`, which replaces `pgvecto-rs`. VectorChord support can be toggled with the option `services.immich.database.enableVectorChord`. Additionally, `pgvecto-rs` support is now disabled from NixOS 25.11 onwards using the option `services.immich.database.enableVectors`. This option will be removed fully in the future once Immich drops support for `pgvecto-rs` fully. See [Immich migration instructions](#module-services-immich-vectorchord-migration)
|
- Immich now has support for [VectorChord](https://github.com/tensorchord/VectorChord) when using the PostgreSQL configuration provided by `services.immich.database.enable`, which replaces `pgvecto-rs`. VectorChord support can be toggled with the option `services.immich.database.enableVectorChord`. Additionally, `pgvecto-rs` support is now disabled from NixOS 25.11 onwards using the option `services.immich.database.enableVectors`. This option will be removed fully in the future once Immich drops support for `pgvecto-rs` fully. See [Immich migration instructions](#module-services-immich-vectorchord-migration)
|
||||||
|
|||||||
@@ -5,164 +5,39 @@
|
|||||||
utils,
|
utils,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
cfg = config.services.logind;
|
|
||||||
|
|
||||||
logindHandlerType = lib.types.enum [
|
|
||||||
"ignore"
|
|
||||||
"poweroff"
|
|
||||||
"reboot"
|
|
||||||
"halt"
|
|
||||||
"kexec"
|
|
||||||
"suspend"
|
|
||||||
"hibernate"
|
|
||||||
"hybrid-sleep"
|
|
||||||
"suspend-then-hibernate"
|
|
||||||
"sleep"
|
|
||||||
"lock"
|
|
||||||
];
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
options.services.logind = {
|
options.services.logind = {
|
||||||
extraConfig = lib.mkOption {
|
settings.Login = lib.mkOption {
|
||||||
default = "";
|
|
||||||
type = lib.types.lines;
|
|
||||||
example = "IdleAction=lock";
|
|
||||||
description = ''
|
description = ''
|
||||||
Extra config options for systemd-logind.
|
Settings option for systemd-logind.
|
||||||
See {manpage}`logind.conf(5)`
|
See {manpage}`logind.conf(5)` for available options.
|
||||||
for available options.
|
|
||||||
'';
|
'';
|
||||||
};
|
type = lib.types.submodule {
|
||||||
|
freeformType = lib.types.attrsOf utils.systemdUtils.unitOptions.unitOption;
|
||||||
|
options.KillUserProcesses = lib.mkOption {
|
||||||
|
default = false;
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Specifies whether the processes of a user should be killed
|
||||||
|
when the user logs out. If true, the scope unit corresponding
|
||||||
|
to the session and all processes inside that scope will be
|
||||||
|
terminated. If false, the scope is "abandoned"
|
||||||
|
(see {manpage}`systemd.scope(5)`),
|
||||||
|
and processes are not killed.
|
||||||
|
|
||||||
killUserProcesses = lib.mkOption {
|
See {manpage}`logind.conf(5)` for more details.
|
||||||
default = false;
|
|
||||||
type = lib.types.bool;
|
|
||||||
description = ''
|
|
||||||
Specifies whether the processes of a user should be killed
|
|
||||||
when the user logs out. If true, the scope unit corresponding
|
|
||||||
to the session and all processes inside that scope will be
|
|
||||||
terminated. If false, the scope is "abandoned"
|
|
||||||
(see {manpage}`systemd.scope(5)`),
|
|
||||||
and processes are not killed.
|
|
||||||
|
|
||||||
See {manpage}`logind.conf(5)`
|
Defaulted to false in nixpkgs because many tools that rely on
|
||||||
for more details.
|
persistent user processes—like `tmux`, `screen`, `mosh`, `VNC`,
|
||||||
'';
|
`nohup`, and more — would break by the systemd-default behavior.
|
||||||
};
|
'';
|
||||||
|
};
|
||||||
powerKey = lib.mkOption {
|
};
|
||||||
default = "poweroff";
|
default = { };
|
||||||
example = "ignore";
|
example = {
|
||||||
type = logindHandlerType;
|
KillUserProcesses = false;
|
||||||
|
HandleLidSwitch = "ignore";
|
||||||
description = ''
|
};
|
||||||
Specifies what to do when the power key is pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
powerKeyLongPress = lib.mkOption {
|
|
||||||
default = "ignore";
|
|
||||||
example = "reboot";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the power key is long-pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
rebootKey = lib.mkOption {
|
|
||||||
default = "reboot";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the reboot key is pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
rebootKeyLongPress = lib.mkOption {
|
|
||||||
default = "poweroff";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the reboot key is long-pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
suspendKey = lib.mkOption {
|
|
||||||
default = "suspend";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the suspend key is pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
suspendKeyLongPress = lib.mkOption {
|
|
||||||
default = "hibernate";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the suspend key is long-pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
hibernateKey = lib.mkOption {
|
|
||||||
default = "hibernate";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the hibernate key is pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
hibernateKeyLongPress = lib.mkOption {
|
|
||||||
default = "ignore";
|
|
||||||
example = "suspend";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the hibernate key is long-pressed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
lidSwitch = lib.mkOption {
|
|
||||||
default = "suspend";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the laptop lid is closed.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
lidSwitchExternalPower = lib.mkOption {
|
|
||||||
default = cfg.lidSwitch;
|
|
||||||
defaultText = lib.literalExpression "services.logind.lidSwitch";
|
|
||||||
example = "ignore";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the laptop lid is closed
|
|
||||||
and the system is on external power. By default use
|
|
||||||
the same action as specified in services.logind.lidSwitch.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
lidSwitchDocked = lib.mkOption {
|
|
||||||
default = "ignore";
|
|
||||||
example = "suspend";
|
|
||||||
type = logindHandlerType;
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Specifies what to do when the laptop lid is closed
|
|
||||||
and another screen is added.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -187,24 +62,10 @@ in
|
|||||||
"user-runtime-dir@.service"
|
"user-runtime-dir@.service"
|
||||||
];
|
];
|
||||||
|
|
||||||
environment.etc = {
|
environment.etc."systemd/logind.conf".text = ''
|
||||||
"systemd/logind.conf".text = ''
|
[Login]
|
||||||
[Login]
|
${utils.systemdUtils.lib.attrsToSection config.services.logind.settings.Login}
|
||||||
KillUserProcesses=${if cfg.killUserProcesses then "yes" else "no"}
|
'';
|
||||||
HandlePowerKey=${cfg.powerKey}
|
|
||||||
HandlePowerKeyLongPress=${cfg.powerKeyLongPress}
|
|
||||||
HandleRebootKey=${cfg.rebootKey}
|
|
||||||
HandleRebootKeyLongPress=${cfg.rebootKeyLongPress}
|
|
||||||
HandleSuspendKey=${cfg.suspendKey}
|
|
||||||
HandleSuspendKeyLongPress=${cfg.suspendKeyLongPress}
|
|
||||||
HandleHibernateKey=${cfg.hibernateKey}
|
|
||||||
HandleHibernateKeyLongPress=${cfg.hibernateKeyLongPress}
|
|
||||||
HandleLidSwitch=${cfg.lidSwitch}
|
|
||||||
HandleLidSwitchExternalPower=${cfg.lidSwitchExternalPower}
|
|
||||||
HandleLidSwitchDocked=${cfg.lidSwitchDocked}
|
|
||||||
${cfg.extraConfig}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Restarting systemd-logind breaks X11
|
# Restarting systemd-logind breaks X11
|
||||||
# - upstream commit: https://cgit.freedesktop.org/xorg/xserver/commit/?id=dc48bd653c7e101
|
# - upstream commit: https://cgit.freedesktop.org/xorg/xserver/commit/?id=dc48bd653c7e101
|
||||||
@@ -218,4 +79,33 @@ in
|
|||||||
systemd.services."user-runtime-dir@".stopIfChanged = false;
|
systemd.services."user-runtime-dir@".stopIfChanged = false;
|
||||||
systemd.services."user-runtime-dir@".restartIfChanged = false;
|
systemd.services."user-runtime-dir@".restartIfChanged = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
imports =
|
||||||
|
let
|
||||||
|
settingsRename =
|
||||||
|
old: new:
|
||||||
|
lib.mkRenamedOptionModule
|
||||||
|
[ "services" "logind" old ]
|
||||||
|
[ "services" "logind" "settings" "Login" new ];
|
||||||
|
in
|
||||||
|
[
|
||||||
|
(lib.mkRemovedOptionModule [
|
||||||
|
"services"
|
||||||
|
"logind"
|
||||||
|
"extraConfig"
|
||||||
|
] "Use services.logind.settings.Login instead.")
|
||||||
|
|
||||||
|
(settingsRename "killUserProcesses" "KillUserProcesses")
|
||||||
|
(settingsRename "powerKey" "HandlePowerKey")
|
||||||
|
(settingsRename "powerKeyLongPress" "HandlePowerKeyLongPress")
|
||||||
|
(settingsRename "rebootKey" "HandleRebootKey")
|
||||||
|
(settingsRename "rebootKeyLongPress" "HandleRebootKeyLongPress")
|
||||||
|
(settingsRename "suspendKey" "HandleSuspendKey")
|
||||||
|
(settingsRename "suspendKeyLongPress" "HandleSuspendKeyLongPress")
|
||||||
|
(settingsRename "hibernateKey" "HandleHibernateKey")
|
||||||
|
(settingsRename "hibernateKeyLongPress" "HandleHibernateKeyLongPress")
|
||||||
|
(settingsRename "lidSwitch" "HandleLidSwitch")
|
||||||
|
(settingsRename "lidSwitchExternalPower" "HandleLidSwitchExternalPower")
|
||||||
|
(settingsRename "lidSwitchDocked" "HandleLidSwitchDocked")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user