nixos/systemd: convert sleep.extraConfig to RFC42-style settings

Replace the stringly-typed systemd.sleep.extraConfig option (types.lines)
with systemd.sleep.settings.Sleep, a freeformType submodule using
types.attrsOf unitOption. This follows the same pattern already used by
systemd.settings.Manager, services.logind.settings.Login, and other
systemd modules that have been migrated to RFC42.

The sleep.conf file is now rendered via settingsToSections instead of raw
string interpolation.

A mkRemovedOptionModule is added for the old option path to give users a
clear migration message.
This commit is contained in:
Jamie Magee
2026-02-22 21:55:03 -08:00
parent 61258584a9
commit d446c73c0a
2 changed files with 18 additions and 10 deletions
@@ -181,6 +181,8 @@ See <https://github.com/NixOS/nixpkgs/issues/481673>.
- [services.resolved](#opt-services.resolved.enable) module was converted to RFC42-style settings. The moved options have also been renamed to match the upstream names. Aliases mean current configs will continue to function, but users should move to the new options as convenient.
- `systemd.sleep.extraConfig` was replaced by [RFC 0042](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md)-compliant `systemd.sleep.settings.Sleep`, which is used to generate the `sleep.conf` configuration file. See {manpage}`sleep.conf.d(5)` for available options.
- Support for Bluetooth audio based on `bluez-alsa` has been added to the `hardware.alsa` module. It can be enabled with the new [enableBluetooth](#opt-hardware.alsa.enableBluetooth) option.
- `services.openssh` now supports generating host SSH keys by setting `services.openssh.generateHostKeys = true` while leaving `services.openssh.enable` disabled. This is particularly useful for systems that have no need of an SSH daemon but want SSH host keys for other purposes such as using agenix or sops-nix.
+16 -10
View File
@@ -470,13 +470,17 @@ in
'';
};
sleep.extraConfig = mkOption {
default = "";
type = types.lines;
example = "HibernateDelaySec=1h";
sleep.settings.Sleep = mkOption {
default = { };
type = lib.types.submodule {
freeformType = types.attrsOf unitOption;
};
example = {
HibernateDelaySec = "1h";
};
description = ''
Extra config options for systemd sleep state logic.
See {manpage}`sleep.conf.d(5)` man page for available options.
Options for systemd sleep state logic. See {manpage}`sleep.conf.d(5)` man page
for available options.
'';
};
@@ -637,10 +641,7 @@ in
"systemd/system.conf".text = settingsToSections cfg.settings;
"systemd/sleep.conf".text = ''
[Sleep]
${cfg.sleep.extraConfig}
'';
"systemd/sleep.conf".text = settingsToSections cfg.sleep.settings;
"systemd/user-generators" = {
source = hooks "user-generators" cfg.user.generators;
@@ -853,6 +854,11 @@ 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.")
(mkRemovedOptionModule [
"systemd"
"sleep"
"extraConfig"
] "Use systemd.sleep.settings.Sleep instead.")
(lib.mkRenamedOptionModule
[ "systemd" "watchdog" "device" ]
[ "systemd" "settings" "Manager" "WatchdogDevice" ]