Merge pull request #90144 from pbogdan/undervolt
nixos/undervolt: misc cleanups / fixes
This commit is contained in:
commit
7dcb8dc239
@ -1,18 +1,32 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.undervolt;
|
cfg = config.services.undervolt;
|
||||||
in {
|
cliArgs = lib.cli.toGNUCommandLineShell {} {
|
||||||
options.services.undervolt = {
|
inherit (cfg)
|
||||||
enable = mkOption {
|
verbose
|
||||||
type = types.bool;
|
temp
|
||||||
default = false;
|
;
|
||||||
description = ''
|
# `core` and `cache` are both intentionally set to `cfg.coreOffset` as according to the undervolt docs:
|
||||||
Whether to undervolt intel cpus.
|
#
|
||||||
'';
|
# 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;
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.undervolt = {
|
||||||
|
enable = mkEnableOption
|
||||||
|
"Intel CPU undervolting service (WARNING: may permanently damage your hardware!)";
|
||||||
|
|
||||||
verbose = mkOption {
|
verbose = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@ -32,58 +46,58 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
coreOffset = mkOption {
|
coreOffset = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The amount of voltage to offset the CPU cores by. Accepts a floating point number.
|
The amount of voltage in mV to offset the CPU cores by.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
gpuOffset = mkOption {
|
gpuOffset = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The amount of voltage to offset the GPU by. Accepts a floating point number.
|
The amount of voltage in mV to offset the GPU by.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
uncoreOffset = mkOption {
|
uncoreOffset = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The amount of voltage to offset uncore by. Accepts a floating point number.
|
The amount of voltage in mV to offset uncore by.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
analogioOffset = mkOption {
|
analogioOffset = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The amount of voltage to offset analogio by. Accepts a floating point number.
|
The amount of voltage in mV to offset analogio by.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
temp = mkOption {
|
temp = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The temperature target. Accepts a floating point number.
|
The temperature target in Celsius degrees.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
tempAc = mkOption {
|
tempAc = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The temperature target on AC power. Accepts a floating point number.
|
The temperature target on AC power in Celsius degrees.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
tempBat = mkOption {
|
tempBat = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.int;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
The temperature target on battery power. Accepts a floating point number.
|
The temperature target on battery power in Celsius degrees.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -100,24 +114,7 @@ in {
|
|||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
Restart = "no";
|
Restart = "no";
|
||||||
|
ExecStart = "${pkgs.undervolt}/bin/undervolt ${cliArgs}";
|
||||||
# `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.
|
|
||||||
ExecStart = ''
|
|
||||||
${pkgs.undervolt}/bin/undervolt \
|
|
||||||
${optionalString cfg.verbose "--verbose"} \
|
|
||||||
${optionalString (cfg.coreOffset != null) "--core ${cfg.coreOffset}"} \
|
|
||||||
${optionalString (cfg.coreOffset != null) "--cache ${cfg.coreOffset}"} \
|
|
||||||
${optionalString (cfg.gpuOffset != null) "--gpu ${cfg.gpuOffset}"} \
|
|
||||||
${optionalString (cfg.uncoreOffset != null) "--uncore ${cfg.uncoreOffset}"} \
|
|
||||||
${optionalString (cfg.analogioOffset != null) "--analogio ${cfg.analogioOffset}"} \
|
|
||||||
${optionalString (cfg.temp != null) "--temp ${cfg.temp}"} \
|
|
||||||
${optionalString (cfg.tempAc != null) "--temp-ac ${cfg.tempAc}"} \
|
|
||||||
${optionalString (cfg.tempBat != null) "--temp-bat ${cfg.tempBat}"}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user