From 6433d954da84df9fa1de1ae728b82d0a29801cea Mon Sep 17 00:00:00 2001 From: Lukas Wurzinger Date: Fri, 28 Nov 2025 18:31:58 +0100 Subject: [PATCH] nixos/undervolt: fix argument conversion --- nixos/modules/services/hardware/undervolt.nix | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/nixos/modules/services/hardware/undervolt.nix b/nixos/modules/services/hardware/undervolt.nix index dd020181a6fe..a2c16f9bd8de 100644 --- a/nixos/modules/services/hardware/undervolt.nix +++ b/nixos/modules/services/hardware/undervolt.nix @@ -16,29 +16,37 @@ let limit != null && window != null ) "Both power limit and window must be set"; "${toString limit} ${toString window}"; - cliArgs = lib.cli.toCommandLineGNU { } { - inherit (cfg) - verbose - temp - turbo - ; - # `core` and `cache` are both intentionally set to `cfg.coreOffset` as according to the undervolt docs: - # - # Core or Cache offsets have no effect. It is not possible to set different offsets for - # CPU Core and Cache. The CPU will take the smaller of the two offsets, and apply that to - # both CPU and Cache. A warning message will be displayed if you attempt to set different offsets. - core = cfg.coreOffset; - cache = cfg.coreOffset; - gpu = cfg.gpuOffset; - uncore = cfg.uncoreOffset; - analogio = cfg.analogioOffset; + cliArgs = + let + optionFormat = optionName: { + option = "--${optionName}"; + sep = null; + explicitBool = false; + }; + in + lib.cli.toCommandLine optionFormat { + inherit (cfg) + verbose + temp + turbo + ; + # `core` and `cache` are both intentionally set to `cfg.coreOffset` as according to the undervolt docs: + # + # Core or Cache offsets have no effect. It is not possible to set different offsets for + # CPU Core and Cache. The CPU will take the smaller of the two offsets, and apply that to + # both CPU and Cache. A warning message will be displayed if you attempt to set different offsets. + core = cfg.coreOffset; + cache = cfg.coreOffset; + gpu = cfg.gpuOffset; + uncore = cfg.uncoreOffset; + analogio = cfg.analogioOffset; - temp-bat = cfg.tempBat; - temp-ac = cfg.tempAc; + temp-bat = cfg.tempBat; + temp-ac = cfg.tempAc; - power-limit-long = mkPLimit cfg.p1.limit cfg.p1.window; - power-limit-short = mkPLimit cfg.p2.limit cfg.p2.window; - }; + power-limit-long = mkPLimit cfg.p1.limit cfg.p1.window; + power-limit-short = mkPLimit cfg.p2.limit cfg.p2.window; + }; in { options.services.undervolt = {