2019-09-25 02:23:59 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2019-09-25 11:43:06 +00:00
|
|
|
cfg = config.hardware.fancontrol;
|
2019-09-25 15:03:56 +00:00
|
|
|
configFile = pkgs.writeText "fan.conf" cfg.config;
|
2019-09-25 02:23:59 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
2019-09-25 11:28:16 +00:00
|
|
|
options.hardware.fancontrol = {
|
2019-09-25 15:03:56 +00:00
|
|
|
enable = mkEnableOption "fancontrol (requires fancontrol.config)";
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.lines;
|
2019-09-25 15:24:49 +00:00
|
|
|
default = null;
|
2019-09-25 15:03:56 +00:00
|
|
|
example = ''
|
|
|
|
# Configuration file generated by pwmconfig
|
|
|
|
INTERVAL=1
|
|
|
|
DEVPATH=hwmon0=devices/platform/nct6775.656 hwmon1=devices/pci0000:00/0000:00:18.3
|
|
|
|
DEVNAME=hwmon0=nct6779 hwmon1=k10temp
|
|
|
|
FCTEMPS=hwmon0/pwm2=hwmon1/temp1_input
|
|
|
|
FCFANS=hwmon0/pwm2=hwmon0/fan2_input
|
|
|
|
MINTEMP=hwmon0/pwm2=25
|
|
|
|
MAXTEMP=hwmon0/pwm2=60
|
|
|
|
MINSTART=hwmon0/pwm2=25
|
|
|
|
MINSTOP=hwmon0/pwm2=10
|
|
|
|
MINPWM=hwmon0/pwm2=0
|
|
|
|
MAXPWM=hwmon0/pwm2=255
|
|
|
|
'';
|
2019-09-25 15:31:20 +00:00
|
|
|
description = "Contents for configuration file. See <citerefentry><refentrytitle>pwmconfig</refentrytitle><manvolnum>8</manvolnum></citerefentry>.";
|
2019-09-25 02:23:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-09-25 15:03:56 +00:00
|
|
|
|
2019-09-25 02:23:59 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.fancontrol = {
|
|
|
|
description = "Fan speed control from lm_sensors";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2019-09-25 15:03:56 +00:00
|
|
|
ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${configFile}";
|
2019-09-25 02:23:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|