From 07abe18272c38d5208a29338f17a011f6ae34ab1 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Thu, 12 Jun 2025 20:51:24 +0300 Subject: [PATCH 1/2] nixos/dwm-status: use structured RFC0042-style settings --- .../manual/release-notes/rl-2511.section.md | 2 + nixos/modules/services/misc/dwm-status.nix | 69 ++++++++++++------- 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index d0da48a610d6..33323a4f0300 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -44,6 +44,8 @@ - The `services.siproxd` module has been removed as `siproxd` is unmaintained and broken with libosip 5.x. +- `services.dwm-status.extraConfig` was replaced by [RFC0042](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md)-compliant [](#opt-services.dwm-status.settings), which is used to generate the config file. `services.dwm-status.order` is now moved to [](#opt-services.dwm-status.settings.order), as it's a part of the config file. + - `renovate` was updated to v40. See the [upstream release notes](https://github.com/renovatebot/renovate/releases/tag/40.0.0) for breaking changes. ## Other Notable Changes {#sec-release-25.11-notable-changes} diff --git a/nixos/modules/services/misc/dwm-status.nix b/nixos/modules/services/misc/dwm-status.nix index f0df70051d48..542eaec4bdf0 100644 --- a/nixos/modules/services/misc/dwm-status.nix +++ b/nixos/modules/services/misc/dwm-status.nix @@ -7,16 +7,23 @@ let cfg = config.services.dwm-status; - order = lib.concatMapStringsSep "," (feature: ''"${feature}"'') cfg.order; + format = pkgs.formats.toml { }; - configFile = pkgs.writeText "dwm-status.toml" '' - order = [${order}] - - ${cfg.extraConfig} - ''; + configFile = format.generate "dwm-status.toml" cfg.settings; in { + imports = [ + (lib.mkRenamedOptionModule + [ "services" "dwm-status" "order" ] + [ "services" "dwm-status" "settings" "order" ] + ) + (lib.mkRemovedOptionModule [ + "services" + "dwm-status" + "extraConfig" + ] "Use services.dwm-status.settings instead.") + ]; ###### interface @@ -30,27 +37,41 @@ in example = "dwm-status.override { enableAlsaUtils = false; }"; }; - order = lib.mkOption { - type = lib.types.listOf ( - lib.types.enum [ - "audio" - "backlight" + settings = lib.mkOption { + type = lib.types.submodule { + freeformType = format.type; + options.order = lib.mkOption { + type = lib.types.listOf ( + lib.types.enum [ + "audio" + "backlight" + "battery" + "cpu_load" + "network" + "time" + ] + ); + default = [ ]; + description = '' + List of enabled features in order. + ''; + }; + }; + default = { }; + example = { + order = [ "battery" "cpu_load" - "network" "time" - ] - ); + ]; + time = { + format = "%F %a %r"; + update_seconds = true; + }; + }; description = '' - List of enabled features in order. - ''; - }; - - extraConfig = lib.mkOption { - type = lib.types.lines; - default = ""; - description = '' - Extra config in TOML format. + Config options for dwm-status, see https://github.com/Gerschtli/dwm-status#configuration + for available options. ''; }; @@ -62,7 +83,7 @@ in config = lib.mkIf cfg.enable { - services.upower.enable = lib.mkIf (lib.elem "battery" cfg.order) true; + services.upower.enable = lib.mkIf (lib.elem "battery" cfg.settings.order) true; systemd.user.services.dwm-status = { description = "Highly performant and configurable DWM status service"; From daf30d2fcd017ffd6d0044065cc5c59ee9f38bc0 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 14 Jun 2025 13:16:36 +0300 Subject: [PATCH 2/2] nixos/dwm-status: clean up whitespace and old comments --- nixos/modules/services/misc/dwm-status.nix | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/nixos/modules/services/misc/dwm-status.nix b/nixos/modules/services/misc/dwm-status.nix index 542eaec4bdf0..b7031808287b 100644 --- a/nixos/modules/services/misc/dwm-status.nix +++ b/nixos/modules/services/misc/dwm-status.nix @@ -25,12 +25,8 @@ in ] "Use services.dwm-status.settings instead.") ]; - ###### interface - options = { - services.dwm-status = { - enable = lib.mkEnableOption "dwm-status user service"; package = lib.mkPackageOption pkgs "dwm-status" { @@ -74,25 +70,17 @@ in for available options. ''; }; - }; - }; - ###### implementation - config = lib.mkIf cfg.enable { - services.upower.enable = lib.mkIf (lib.elem "battery" cfg.settings.order) true; systemd.user.services.dwm-status = { description = "Highly performant and configurable DWM status service"; wantedBy = [ "graphical-session.target" ]; partOf = [ "graphical-session.target" ]; - serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile} --quiet"; }; - }; - }