Thinkfan not working in nixos

I’m trying to configure thinkfan on my Thinkpad X1 Extreme 2nd. I have following config in configuration.nix

boot.kernelPackages = pkgs.linuxPackages_testing;
initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "battery" "thinkpad_acpi"];
 services = {
    thinkfan = {
      enable = true;
      levels = ''
        (0,    0,      43)
        (1,    35,     45)
        (2,    38,     48)
        (3,    42,     53)
        (4,    45,     58)
        (5,    48,     62)
        (6,    51,     65)
        (7,    54,     68)
        (8,    56,     70)
        (9,    58,    999)
      '';
    };
  };

When I run thinkfan, it report this error:
ERROR: Module thinkpad_acpi doesn't seem to support fan_control

I run systool -vm thinkpad_acpi to check parameters of thinkpad_acpi, here is output:

Module = "thinkpad_acpi"

  Attributes:
    coresize            = "98304"
    initsize            = "0"
    initstate           = "live"
    refcnt              = "0"
    srcversion          = "3F92DC372A74647BCEDD704"
    taint               = ""
    uevent              = <store method only>
    version             = "0.26"

  Parameters:
    brightness_enable   = "2"
    brightness_mode     = "4"
    enable              = "Y"
    experimental        = "0"
    fan_control         = "N"
    force_load          = "N"
    id                  = "ThinkPadEC"
    index               = "-536870912"
    software_mute       = "Y"
    volume_capabilities = "0"
    volume_control      = "N"
    volume_mode         = "3"

  Sections:

It seem like experimental and fan_control parameters has not been set correctly. So I checked /etc/modprobe.d/nixos.conf, it contains this line:

options thinkpad_acpi experimental=1 fan_control=1

I think that line was configured by nixos thinkfan module to enable fan_control feature in thinkpad_acpi module but seem like it does not work as expected. How can I fix that

1 Like

Hi there,
I am just doing my first baby steps with NixOS, ran into the same error message, and discovered your post. Reloading the module via (as root)

modprobe -r thinkpad_acpi
modprobe thinkpad_acpi

did the trick for me and NixOS happily accepted my new configuration.

1 Like

Thank you, that works. I added this to configuration.nix so that I don’t have to run those command again after the switch:

  systemd.services.thinkfan.preStart = "
    /run/current-system/sw/bin/modprobe  -r thinkpad_acpi && /run/current-system/sw/bin/modprobe thinkpad_acpi
  ";
1 Like