diff options
author | Evils <evils.devils@protonmail.com> | 2019-09-25 17:03:56 +0200 |
---|---|---|
committer | Evils <evils.devils@protonmail.com> | 2019-09-25 17:05:09 +0200 |
commit | 401b0b0c7bcda99c5da5c448fb3f52bcee79a031 (patch) | |
tree | 95ad4b616c5482375ad428c83353ae103574effd /nixos/modules/services | |
parent | 5fe72ee446dbaf08a14ae7172ee2e0fed2b3121b (diff) | |
download | nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.tar nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.tar.gz nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.tar.bz2 nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.tar.lz nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.tar.xz nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.tar.zst nixlib-401b0b0c7bcda99c5da5c448fb3f52bcee79a031.zip |
fancontrol: load config from configuration.nix
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/hardware/fancontrol.nix | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index 30074f81aed2..1689b670b497 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -4,30 +4,43 @@ with lib; let cfg = config.hardware.fancontrol; + configFile = pkgs.writeText "fan.conf" cfg.config; in { options.hardware.fancontrol = { - enable = mkEnableOption "fancontrol (requires a configuration file, see pwmconfig)"; - - configFile = mkOption { - type = types.str; - default = "/etc/fancontrol"; - example = "/home/user/.config/fancontrol"; - description = "Path to the configuration file, likely generated with pwmconfig."; + enable = mkEnableOption "fancontrol (requires fancontrol.config)"; + + config = mkOption { + type = types.lines; + default = /etc/fancontrol; + 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 + ''; + description = "Configuration likely generated with pwmconfig."; }; }; + config = mkIf cfg.enable { systemd.services.fancontrol = { description = "Fan speed control from lm_sensors"; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; - ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${cfg.configFile}"; + ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${configFile}"; }; }; }; - - } |