aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-09 18:55:19 +0000
committerMx Kookie <kookie@spacekookie.de>2020-12-09 18:55:19 +0000
commit80d90d9b204f7c17912740f9f414fe5d59f293ba (patch)
tree5f2065a06e724270610760d59d01c6888b375a46 /infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix
parent3a31a84c7d3e589035ad08499206aac44a81f424 (diff)
parent83cbad92d73216bb0d9187c56cce0b91f9121d5a (diff)
Merge commit '83cbad92d73216bb0d9187c56cce0b91f9121d5a' into main
Diffstat (limited to 'infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix')
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix46
1 files changed, 44 insertions, 2 deletions
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix b/infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix
index 054ffa35050a..9c2f78a755dd 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/hardware/undervolt.nix
+++ b/infra/libkookie/nixpkgs/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}";
};
};