From d446c73c0a96c29d2e2413f523f73c8e246cf069 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Sun, 22 Feb 2026 21:42:38 -0800 Subject: [PATCH] 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. --- .../manual/release-notes/rl-2605.section.md | 2 ++ nixos/modules/system/boot/systemd.nix | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2605.section.md b/nixos/doc/manual/release-notes/rl-2605.section.md index 1ec3860bcac2..e0a96c41d056 100644 --- a/nixos/doc/manual/release-notes/rl-2605.section.md +++ b/nixos/doc/manual/release-notes/rl-2605.section.md @@ -181,6 +181,8 @@ See . - [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. diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 4b7bb1271392..dd41f389d5b8 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -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" ]