diff options
author | Benjamin Staffin <bstaffin@singlestore.com> | 2023-06-25 12:35:47 -0400 |
---|---|---|
committer | Benjamin Staffin <bstaffin@singlestore.com> | 2023-08-23 13:25:29 -0400 |
commit | 12b3178bd22e0b11ba44a6db2cbb1069178f8e14 (patch) | |
tree | 8c5bd53f64f7d6265b3d8bebeeacb0844ca1b254 /nixos/modules/services/hardware | |
parent | 8deb8a1fcf0cb1b91696fed999425cbe22e01536 (diff) | |
download | nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.tar nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.tar.gz nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.tar.bz2 nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.tar.lz nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.tar.xz nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.tar.zst nixpkgs-12b3178bd22e0b11ba44a6db2cbb1069178f8e14.zip |
nixos/hddfancontrol: initial module & test
Diffstat (limited to 'nixos/modules/services/hardware')
-rw-r--r-- | nixos/modules/services/hardware/hddfancontrol.nix | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/hddfancontrol.nix b/nixos/modules/services/hardware/hddfancontrol.nix new file mode 100644 index 00000000000..463f63cc494 --- /dev/null +++ b/nixos/modules/services/hardware/hddfancontrol.nix @@ -0,0 +1,67 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.hddfancontrol; + types = lib.types; +in + +{ + options = { + + services.hddfancontrol.enable = lib.mkEnableOption "hddfancontrol daemon"; + + services.hddfancontrol.disks = lib.mkOption { + type = with types; listOf path; + default = []; + description = lib.mdDoc '' + Drive(s) to get temperature from + ''; + example = ["/dev/sda"]; + }; + + services.hddfancontrol.pwmPaths = lib.mkOption { + type = with types; listOf path; + default = []; + description = lib.mdDoc '' + 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; + description = lib.mdDoc '' + Probe temperature using smartctl instead of hddtemp or hdparm + ''; + }; + + services.hddfancontrol.extraArgs = lib.mkOption { + type = with types; listOf str; + default = []; + description = lib.mdDoc '' + 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 = { + enable = true; + wantedBy = [ "multi-user.target" ]; + environment.HDDFANCONTROL_ARGS = lib.escapeShellArgs args; + }; + } + ); +} |