mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
fancontrol: load config from configuration.nix
This commit is contained in:
parent
5fe72ee446
commit
401b0b0c7b
1 changed files with 22 additions and 9 deletions
|
@ -4,30 +4,43 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.hardware.fancontrol;
|
cfg = config.hardware.fancontrol;
|
||||||
|
configFile = pkgs.writeText "fan.conf" cfg.config;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
options.hardware.fancontrol = {
|
options.hardware.fancontrol = {
|
||||||
enable = mkEnableOption "fancontrol (requires a configuration file, see pwmconfig)";
|
enable = mkEnableOption "fancontrol (requires fancontrol.config)";
|
||||||
|
|
||||||
configFile = mkOption {
|
config = mkOption {
|
||||||
type = types.str;
|
type = types.lines;
|
||||||
default = "/etc/fancontrol";
|
default = /etc/fancontrol;
|
||||||
example = "/home/user/.config/fancontrol";
|
example = ''
|
||||||
description = "Path to the configuration file, likely generated with pwmconfig.";
|
# 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 {
|
config = mkIf cfg.enable {
|
||||||
systemd.services.fancontrol = {
|
systemd.services.fancontrol = {
|
||||||
description = "Fan speed control from lm_sensors";
|
description = "Fan speed control from lm_sensors";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${cfg.configFile}";
|
ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${configFile}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue