2023-06-25 17:35:47 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.hddfancontrol;
|
|
|
|
types = lib.types;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
2024-04-13 13:54:15 +01:00
|
|
|
services.hddfancontrol.enable = lib.mkEnableOption "hddfancontrol daemon";
|
2023-06-25 17:35:47 +01:00
|
|
|
|
|
|
|
services.hddfancontrol.disks = lib.mkOption {
|
|
|
|
type = with types; listOf path;
|
|
|
|
default = [];
|
2024-04-13 13:54:15 +01:00
|
|
|
description = ''
|
2023-06-25 17:35:47 +01:00
|
|
|
Drive(s) to get temperature from
|
|
|
|
'';
|
|
|
|
example = ["/dev/sda"];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.hddfancontrol.pwmPaths = lib.mkOption {
|
|
|
|
type = with types; listOf path;
|
|
|
|
default = [];
|
2024-04-13 13:54:15 +01:00
|
|
|
description = ''
|
2023-06-25 17:35:47 +01:00
|
|
|
PWM filepath(s) to control fan speed (under /sys)
|
|
|
|
'';
|
|
|
|
example = ["/sys/class/hwmon/hwmon2/pwm1"];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.hddfancontrol.smartctl = lib.mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 13:54:15 +01:00
|
|
|
description = ''
|
2023-06-25 17:35:47 +01:00
|
|
|
Probe temperature using smartctl instead of hddtemp or hdparm
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
services.hddfancontrol.extraArgs = lib.mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [];
|
2024-04-13 13:54:15 +01:00
|
|
|
description = ''
|
2023-06-25 17:35:47 +01:00
|
|
|
Extra commandline arguments for hddfancontrol
|
|
|
|
'';
|
|
|
|
example = ["--pwm-start-value=32"
|
|
|
|
"--pwm-stop-value=0"
|
|
|
|
"--spin-down-time=900"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable (
|
|
|
|
let args = lib.concatLists [
|
|
|
|
["-d"] cfg.disks
|
|
|
|
["-p"] cfg.pwmPaths
|
|
|
|
(lib.optional cfg.smartctl "--smartctl")
|
|
|
|
cfg.extraArgs
|
|
|
|
]; in {
|
|
|
|
systemd.packages = [pkgs.hddfancontrol];
|
|
|
|
|
|
|
|
systemd.services.hddfancontrol = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
environment.HDDFANCONTROL_ARGS = lib.escapeShellArgs args;
|
2024-01-22 02:08:34 +00:00
|
|
|
serviceConfig = {
|
|
|
|
# Hardening
|
|
|
|
PrivateNetwork = true;
|
|
|
|
};
|
2023-06-25 17:35:47 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|