Trouble Controlling Case Fan via PWM

Reposting because I realise I forgot a title!! Sorry

My goal is to adjust the speed of one of my desktops case fans based on the temperature of my GPU.

I need to do this because my GPU has no internal fans, and I need to cool it with a custom shroud.

The issue is that the fan can not be detected by lm_sensors

The fan is connected to the motherboard via a 4-pin PWM “chasis fan” header, and I have tried all headers.

I’ve confirmed the fan works via the motherboard BIOS, but it cannot be controlled via nixos. (Fan control through the motherboard isn’t a solution because that doesn’t allow me to monitor the gpu)

Relevant section of my configuration.nix file
I’ve tried with and without each added section

The kernel module nct6775 should support my motherboard (nct6791D)

boot = {
		kernelParams = [ "acpi_enfore_resources=lax" ];
		kernelModules = [ "coretemp" "nct6775" "wl" ];
  	    extraModprobeConfig = ''
				options nct6775 force_id=0x290 
		'';
		extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];

		loader = {
				systemd-boot.enable = true;
				efi.canTouchEfiVariables = true;
		};
};

With and without extraModprobeConfig

force_id=0x209:

[user@nixosserver:~]$ lsmod | grep nct6775
nct6775_core           81920  0
[user@nixosserver:/etc/nixos]$ dmesg | grep nct6775
(no result)

force_id=0 OR taking out extraModprobeConfig:

[user@nixosserver:/etc/nixos]$ lsmod | grep nct6775
nct6775                40960  0
nct6775_core           81920  1 nct6775
hwmon_vid              12288  1 nct6775

Regardless of extraModprobeConfig

Seems to be nothing in /sys/class/hwmon/

From sudo sensors-detect, only interesting result was:

Driver `nct6775':
  * ISA bus, address 0x290
    Chip `Nuvoton NCT6791D Super IO Sensors' (confidence: 9)
[user@nixosserver:~]$ sudo pwmconfig
# pwmconfig version 3.6.0
This program will search your sensors for pulse width modulation (pwm)
controls, and test each one to see if it controls a fan on
your motherboard. Note that many motherboards do not have pwm
circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.
The program will attempt to restore each fan to full speed
after testing. However, it is ** very important ** that you
physically verify that the fans have been to full speed
after the program has completed.
[user@nixosserver:/etc/nixos]$ dmesg | grep nct6775
[   10.311925] nct6775: Found NCT6791D or compatible chip at 0x2e:0x290
[user@nixosserver:/etc/nixos]$ sensors -u
nvme-pci-0300
Adapter: PCI adapter
Composite:
  temp1_input: 35.850
  temp1_max: 84.850
  temp1_min: -273.150
  temp1_crit: 84.850
  temp1_alarm: 0.000
Sensor 1:
  temp2_input: 35.850
  temp2_max: 65261.850
  temp2_min: -273.150
Sensor 2:
  temp3_input: 43.850
  temp3_max: 65261.850
  temp3_min: -273.150

nouveau-pci-0100
Adapter: PCI adapter
temp1:
  temp1_input: 34.000
  temp1_max: 95.000
  temp1_max_hyst: 3.000
  temp1_crit: 105.000
  temp1_crit_hyst: 5.000
  temp1_emergency: 135.000
  temp1_emergency_hyst: 5.000

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:
  temp1_input: 39.000
  temp1_max: 77.000
  temp1_crit: 87.000
  temp1_crit_alarm: 0.000
Core 0:
  temp2_input: 28.000
  temp2_max: 77.000
  temp2_crit: 87.000
  temp2_crit_alarm: 0.000
Core 1:
  temp3_input: 32.000
  temp3_max: 77.000
  temp3_crit: 87.000
  temp3_crit_alarm: 0.000
Core 2:
  temp4_input: 27.000
  temp4_max: 77.000
  temp4_crit: 87.000
  temp4_crit_alarm: 0.000
Core 3:
  temp5_input: 29.000
  temp5_max: 77.000
  temp5_crit: 87.000
  temp5_crit_alarm: 0.000
Core 4:
  temp6_input: 32.000
  temp6_max: 77.000
  temp6_crit: 87.000
  temp6_crit_alarm: 0.000
Core 5:
  temp7_input: 28.000
  temp7_max: 77.000
  temp7_crit: 87.000
  temp7_crit_alarm: 0.000
Core 6:
  temp8_input: 26.000
  temp8_max: 77.000
  temp8_crit: 87.000
  temp8_crit_alarm: 0.000
Core 7:
  temp9_input: 27.000
  temp9_max: 77.000
  temp9_crit: 87.000
  temp9_crit_alarm: 0.000

Computer Specs:
Cpu: Intel(R) Xeon(R) E5-2630 v3 @ 2.40GHz
Motherboard: X99-Deluxe-Series
Ram: 1 stick of 8GB DDR4
Gpu: Attempted with AMD radeon instinct mi50 & nvidia gtx 1050ti

NixOS: 24.05.7376.b134951a4c9f (Uakari)
Kernal: 6.6.68

Any help would be greatly appreciated :slight_smile: thanks
If this is a lost cause, any other solutions would be great as well, I’m not set on using lmsensors

Whatever config that yields this is the one what you want, from there pwmconfig and lm_sensors should be working, maybe some confusion happened as you were trying different combinations?

1 Like

Hey, thanks for the response!

Unfortunately not though, after seeing that message the result of running sensors is the one I posted.

What does ls /sys/devices/platform/nct*/hwmon/hwmon*/ | grep 'pwm\d$' print?

If it prints nothing that means the module can’t control the fans’ PWM on your hardware.

You should try upgrading to NixOS 24.11, maybe the newer kernel has improved support.

Hey,

Tthere are no directories in platform containing nct.

One thing that may I be important I didn’t include though is in sensors-detect it told me:
“You should now start the lm_sensors service to load the required
kernel modules.” I haven’t done this, if it’s necessary how do I activate the service through nixos?


[user@nixosserver:~]$ sudo systemctl start lm_sensors
Failed to start lm_sensors.service: Unit lm_sensors.service not found.

No, the kernel module was loaded already, so I don’t think you need to. Did you configure:

environment.etc."sysconfig/lm_sensors".text = ''
  HWMON_MODULES="nct6775"
'';

I think that + boot.kernelModules, + lm_sensors in environment.systemPackages is all I did to get working sensors and PWM control.