nixos/hddfancontrol: loosen pwmPaths and disks types to str, nixos/hddtemp: allow command substitution for drives (#421862)
This commit is contained in:
@@ -9,21 +9,26 @@ let
|
|||||||
|
|
||||||
cfg = config.hardware.sensor.hddtemp;
|
cfg = config.hardware.sensor.hddtemp;
|
||||||
|
|
||||||
wrapper = pkgs.writeShellScript "hddtemp-wrapper" ''
|
script = ''
|
||||||
set -eEuo pipefail
|
set -eEuo pipefail
|
||||||
|
|
||||||
file=/var/lib/hddtemp/hddtemp.db
|
file=/var/lib/hddtemp/hddtemp.db
|
||||||
|
|
||||||
drives=(${toString (map (e: ''$(realpath ${lib.escapeShellArg e}) '') cfg.drives)})
|
raw_drives=""
|
||||||
|
${lib.concatStringsSep "\n" (map (drives: "raw_drives+=\"${drives} \"") cfg.drives)}
|
||||||
|
drives=""
|
||||||
|
for i in $raw_drives; do
|
||||||
|
drives+=" $(realpath $i)"
|
||||||
|
done
|
||||||
|
|
||||||
cp ${pkgs.hddtemp}/share/hddtemp/hddtemp.db $file
|
cp ${pkgs.hddtemp}/share/hddtemp/hddtemp.db $file
|
||||||
${lib.concatMapStringsSep "\n" (e: "echo ${lib.escapeShellArg e} >> $file") cfg.dbEntries}
|
${lib.concatMapStringsSep "\n" (e: "echo ${lib.escapeShellArg e} >> $file") cfg.dbEntries}
|
||||||
|
|
||||||
exec ${pkgs.hddtemp}/bin/hddtemp ${lib.escapeShellArgs cfg.extraArgs} \
|
${pkgs.hddtemp}/bin/hddtemp ${lib.escapeShellArgs cfg.extraArgs} \
|
||||||
--daemon \
|
--daemon \
|
||||||
--unit=${cfg.unit} \
|
--unit=${cfg.unit} \
|
||||||
--file=$file \
|
--file=$file \
|
||||||
''${drives[@]}
|
$drives
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
@@ -77,9 +82,9 @@ in
|
|||||||
description = "HDD/SSD temperature";
|
description = "HDD/SSD temperature";
|
||||||
documentation = [ "man:hddtemp(8)" ];
|
documentation = [ "man:hddtemp(8)" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
inherit script;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "forking";
|
Type = "forking";
|
||||||
ExecStart = wrapper;
|
|
||||||
StateDirectory = "hddtemp";
|
StateDirectory = "hddtemp";
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
ProtectHome = "tmpfs";
|
ProtectHome = "tmpfs";
|
||||||
|
|||||||
@@ -52,21 +52,30 @@ in
|
|||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
disks = lib.mkOption {
|
disks = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.path;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
Drive(s) to get temperature from
|
Drive(s) to get temperature from
|
||||||
|
|
||||||
|
Can also use command substitution to automatically grab all matching drives; such as all scsi (sas) drives
|
||||||
'';
|
'';
|
||||||
example = [ "/dev/sda" ];
|
example = [
|
||||||
|
"/dev/sda"
|
||||||
|
"`find /dev/disk/by-id -name \"scsi*\" -and -not -name \"*-part*\" -printf \"%p \"`"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
pwmPaths = lib.mkOption {
|
pwmPaths = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.path;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
PWM filepath(s) to control fan speed (under /sys), followed by initial and fan-stop PWM values
|
PWM filepath(s) to control fan speed (under /sys), followed by initial and fan-stop PWM values
|
||||||
|
Can also use command substitution to ensure the correct hwmonX is selected on every boot
|
||||||
'';
|
'';
|
||||||
example = [ "/sys/class/hwmon/hwmon2/pwm1:30:10" ];
|
example = [
|
||||||
|
"/sys/class/hwmon/hwmon2/pwm1:30:10"
|
||||||
|
"`echo /sys/devices/platform/nct6775.656/hwmon/hwmon[[:print:]]`/pwm4:80:20"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
logVerbosity = lib.mkOption {
|
logVerbosity = lib.mkOption {
|
||||||
@@ -151,9 +160,12 @@ in
|
|||||||
documentation = [ "man:hddfancontrol(1)" ];
|
documentation = [ "man:hddfancontrol(1)" ];
|
||||||
after = [ "hddtemp.service" ];
|
after = [ "hddtemp.service" ];
|
||||||
wants = [ "hddtemp.service" ];
|
wants = [ "hddtemp.service" ];
|
||||||
|
script =
|
||||||
|
let
|
||||||
|
argString = lib.strings.concatStringsSep " " (args cnf);
|
||||||
|
in
|
||||||
|
"${lib.getExe pkgs.hddfancontrol} -v ${cnf.logVerbosity} daemon ${argString}";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${lib.getExe pkgs.hddfancontrol} -v ${cnf.logVerbosity} daemon ${lib.escapeShellArgs (args cnf)}";
|
|
||||||
|
|
||||||
CPUSchedulingPolicy = "rr";
|
CPUSchedulingPolicy = "rr";
|
||||||
CPUSchedulingPriority = 49;
|
CPUSchedulingPriority = 49;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user