3
0
Fork 0
forked from mirrors/nixpkgs

nixos/undervolt: simplify CLI args generation

This commit is contained in:
Piotr Bogdan 2020-06-11 15:16:28 +01:00
parent 24e0e05654
commit afae933693

View file

@ -3,6 +3,25 @@
with lib;
let
cfg = config.services.undervolt;
cliArgs = lib.cli.toGNUCommandLineShell {} {
inherit (cfg)
verbose
temp
;
# `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;
};
in
{
options.services.undervolt = {
@ -95,24 +114,7 @@ in
serviceConfig = {
Type = "oneshot";
Restart = "no";
# `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 ${toString cfg.coreOffset}"} \
${optionalString (cfg.coreOffset != null) "--cache ${toString cfg.coreOffset}"} \
${optionalString (cfg.gpuOffset != null) "--gpu ${toString cfg.gpuOffset}"} \
${optionalString (cfg.uncoreOffset != null) "--uncore ${toString cfg.uncoreOffset}"} \
${optionalString (cfg.analogioOffset != null) "--analogio ${toString cfg.analogioOffset}"} \
${optionalString (cfg.temp != null) "--temp ${toString cfg.temp}"} \
${optionalString (cfg.tempAc != null) "--temp-ac ${toString cfg.tempAc}"} \
${optionalString (cfg.tempBat != null) "--temp-bat ${toString cfg.tempBat}"}
'';
ExecStart = "${pkgs.undervolt}/bin/undervolt ${cliArgs}";
};
};