1 { config, lib, pkgs, ... }:
6 cfg = config.hardware.fancontrol;
7 configFile = pkgs.writeText "fancontrol.conf" cfg.config;
11 options.hardware.fancontrol = {
12 enable = mkEnableOption (lib.mdDoc "software fan control (requires fancontrol.config)");
16 description = lib.mdDoc "Required fancontrol configuration file content. See {manpage}`pwmconfig(8)` from the lm_sensors package.";
18 # Configuration file generated by pwmconfig
20 DEVPATH=hwmon3=devices/virtual/thermal/thermal_zone2 hwmon4=devices/platform/f71882fg.656
21 DEVNAME=hwmon3=soc_dts1 hwmon4=f71869a
22 FCTEMPS=hwmon4/device/pwm1=hwmon3/temp1_input
23 FCFANS=hwmon4/device/pwm1=hwmon4/device/fan1_input
24 MINTEMP=hwmon4/device/pwm1=35
25 MAXTEMP=hwmon4/device/pwm1=65
26 MINSTART=hwmon4/device/pwm1=150
27 MINSTOP=hwmon4/device/pwm1=0
32 config = mkIf cfg.enable {
34 systemd.services.fancontrol = {
35 documentation = [ "man:fancontrol(8)" ];
36 description = "software fan control";
37 wantedBy = [ "multi-user.target" ];
38 after = [ "lm_sensors.service" ];
41 Restart = "on-failure";
42 ExecStart = "${pkgs.lm_sensors}/sbin/fancontrol ${configFile}";
46 # On some systems, the fancontrol service does not resume properly after sleep because the pwm status of the fans
47 # is not reset properly. Restarting the service fixes this, in accordance with https://github.com/lm-sensors/lm-sensors/issues/172.
48 powerManagement.resumeCommands = ''
49 systemctl restart fancontrol.service
54 meta.maintainers = [ maintainers.evils ];