From 81b6dec3c8c576227463d7a45fced3e8c49ef1f2 Mon Sep 17 00:00:00 2001 From: Evils Date: Wed, 25 Sep 2019 04:23:59 +0200 Subject: [PATCH 1/8] fancontrol service init --- nixos/modules/module-list.nix | 1 + .../modules/services/hardware/fancontrol.nix | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 nixos/modules/services/hardware/fancontrol.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 775cc05aa0a..a648eef46e5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -328,6 +328,7 @@ ./services/hardware/bluetooth.nix ./services/hardware/bolt.nix ./services/hardware/brltty.nix + ./services/hardware/fancontrol.nix ./services/hardware/freefall.nix ./services/hardware/fwupd.nix ./services/hardware/illum.nix diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix new file mode 100644 index 00000000000..bd4938ab509 --- /dev/null +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.fancontrol; + +in { + + options.services.fancontrol = { + enable = mkOption { + type = types.bool; + default = false; + example = true; + description = "Whether to enable 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."; + }; + }; + + config = mkIf cfg.enable { + systemd.services.fancontrol = { + description = "Fan speed control from lm_sensors"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + User = "root"; + ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${cfg.configFile}"; + }; + }; + }; + + +} From 6c19673fef1e97d99fbad879e28a4272a597ea26 Mon Sep 17 00:00:00 2001 From: Evils-Devils <30512529+Evils-Devils@users.noreply.github.com> Date: Wed, 25 Sep 2019 13:28:16 +0200 Subject: [PATCH 2/8] Update nixos/modules/services/hardware/fancontrol.nix Co-Authored-By: markuskowa --- nixos/modules/services/hardware/fancontrol.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index bd4938ab509..79de0788cac 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -7,7 +7,7 @@ let in { - options.services.fancontrol = { + options.hardware.fancontrol = { enable = mkOption { type = types.bool; default = false; From 30f8bc974ce16f357f7f9d65ce4acd3b3cc8ae42 Mon Sep 17 00:00:00 2001 From: Evils Date: Wed, 25 Sep 2019 13:43:06 +0200 Subject: [PATCH 3/8] update cfg to match section change --- nixos/modules/services/hardware/fancontrol.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index 79de0788cac..1376f7eaebd 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -3,7 +3,7 @@ with lib; let - cfg = config.services.fancontrol; + cfg = config.hardware.fancontrol; in { From baa642e8b3742b6b1b38f6fee61acc290ee8191b Mon Sep 17 00:00:00 2001 From: Evils Date: Wed, 25 Sep 2019 14:42:22 +0200 Subject: [PATCH 4/8] fancontrol: more cleanup --- nixos/modules/services/hardware/fancontrol.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index 1376f7eaebd..fe4ab1e4226 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -8,12 +8,7 @@ let in { options.hardware.fancontrol = { - enable = mkOption { - type = types.bool; - default = false; - example = true; - description = "Whether to enable fancontrol (requires a configuration file, see pwmconfig)"; - }; + enable = mkEnableOption "Whether to enable fancontrol (requires a configuration file, see pwmconfig)"; configFile = mkOption { type = types.str; @@ -29,7 +24,6 @@ in { wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; - User = "root"; ExecStart = "${pkgs.lm_sensors}/bin/fancontrol ${cfg.configFile}"; }; }; From 5fe72ee446dbaf08a14ae7172ee2e0fed2b3121b Mon Sep 17 00:00:00 2001 From: Evils-Devils <30512529+Evils-Devils@users.noreply.github.com> Date: Wed, 25 Sep 2019 14:49:28 +0200 Subject: [PATCH 5/8] Update nixos/modules/services/hardware/fancontrol.nix Co-Authored-By: markuskowa --- nixos/modules/services/hardware/fancontrol.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index fe4ab1e4226..30074f81aed 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -8,7 +8,7 @@ let in { options.hardware.fancontrol = { - enable = mkEnableOption "Whether to enable fancontrol (requires a configuration file, see pwmconfig)"; + enable = mkEnableOption "fancontrol (requires a configuration file, see pwmconfig)"; configFile = mkOption { type = types.str; From 401b0b0c7bcda99c5da5c448fb3f52bcee79a031 Mon Sep 17 00:00:00 2001 From: Evils Date: Wed, 25 Sep 2019 17:03:56 +0200 Subject: [PATCH 6/8] fancontrol: load config from configuration.nix --- .../modules/services/hardware/fancontrol.nix | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index 30074f81aed..1689b670b49 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)"; + enable = mkEnableOption "fancontrol (requires fancontrol.config)"; - configFile = mkOption { - type = types.str; - default = "/etc/fancontrol"; - example = "/home/user/.config/fancontrol"; - description = "Path to the configuration file, likely generated with pwmconfig."; + 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}"; }; }; }; - - } From 44e2ff26b8c348bbbffe4a1996cad24cb0d34b30 Mon Sep 17 00:00:00 2001 From: Evils-Devils <30512529+Evils-Devils@users.noreply.github.com> Date: Wed, 25 Sep 2019 17:24:49 +0200 Subject: [PATCH 7/8] Update nixos/modules/services/hardware/fancontrol.nix Co-Authored-By: markuskowa --- nixos/modules/services/hardware/fancontrol.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index 1689b670b49..32ba6072198 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -13,7 +13,7 @@ in { config = mkOption { type = types.lines; - default = /etc/fancontrol; + default = null; example = '' # Configuration file generated by pwmconfig INTERVAL=1 From 6765f049f2ab8b2819b263a9a6de9fd1b03d7547 Mon Sep 17 00:00:00 2001 From: Evils-Devils <30512529+Evils-Devils@users.noreply.github.com> Date: Wed, 25 Sep 2019 17:31:20 +0200 Subject: [PATCH 8/8] Update nixos/modules/services/hardware/fancontrol.nix Co-Authored-By: markuskowa --- nixos/modules/services/hardware/fancontrol.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index 32ba6072198..616e4add31e 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -28,7 +28,7 @@ in { MINPWM=hwmon0/pwm2=0 MAXPWM=hwmon0/pwm2=255 ''; - description = "Configuration likely generated with pwmconfig."; + description = "Contents for configuration file. See pwmconfig8."; }; };