diff options
author | Atemu <atemu.main@gmail.com> | 2020-06-27 13:55:54 +0200 |
---|---|---|
committer | Atemu <atemu.main@gmail.com> | 2020-08-22 12:27:13 +0200 |
commit | eb4e67505fdf9c521106b3ba9c6f300c77adee6c (patch) | |
tree | 3628e24edb4b51a1964b1cba8f0f93f95d34f9ed /nixos/modules/services | |
parent | bfcd94aab65b8336866b4e8357bc2a03c1f4b4ae (diff) | |
download | nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.tar nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.tar.gz nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.tar.bz2 nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.tar.lz nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.tar.xz nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.tar.zst nixpkgs-eb4e67505fdf9c521106b3ba9c6f300c77adee6c.zip |
undervolt: expose power limits as Nixopts
We no longer escape the flags because the power limit flags want two arguments If we escaped them, we'd only get one argument with an escaped space in it. Undervolt's flags don't have anything in them that would need to be escaped, so that shouldn't break anything
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/hardware/undervolt.nix | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/nixos/modules/services/hardware/undervolt.nix b/nixos/modules/services/hardware/undervolt.nix index 054ffa35050..9c2f78a755d 100644 --- a/nixos/modules/services/hardware/undervolt.nix +++ b/nixos/modules/services/hardware/undervolt.nix @@ -3,7 +3,12 @@ with lib; let cfg = config.services.undervolt; - cliArgs = lib.cli.toGNUCommandLineShell {} { + + mkPLimit = limit: window: + if (isNull limit && isNull window) then null + else assert asserts.assertMsg (!isNull limit && !isNull window) "Both power limit and window must be set"; + "${toString limit} ${toString window}"; + cliArgs = lib.cli.toGNUCommandLine {} { inherit (cfg) verbose temp @@ -21,6 +26,9 @@ let 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; }; in { @@ -104,6 +112,40 @@ in ''; }; + p1.limit = mkOption { + type = with types; nullOr int; + default = null; + description = '' + The P1 Power Limit in Watts. + Both limit and window must be set. + ''; + }; + p1.window = mkOption { + type = with types; nullOr (oneOf [ float int ]); + default = null; + description = '' + The P1 Time Window in seconds. + Both limit and window must be set. + ''; + }; + + p2.limit = mkOption { + type = with types; nullOr int; + default = null; + description = '' + The P2 Power Limit in Watts. + Both limit and window must be set. + ''; + }; + p2.window = mkOption { + type = with types; nullOr (oneOf [ float int ]); + default = null; + description = '' + The P2 Time Window in seconds. + Both limit and window must be set. + ''; + }; + useTimer = mkOption { type = types.bool; default = false; @@ -133,7 +175,7 @@ in serviceConfig = { Type = "oneshot"; Restart = "no"; - ExecStart = "${pkgs.undervolt}/bin/undervolt ${cliArgs}"; + ExecStart = "${pkgs.undervolt}/bin/undervolt ${toString cliArgs}"; }; }; |