Add loadable kernel modules for USB Wi-Fi

Hi folks,

I don’t see my laptop wifi when ip link and before I figure out the problem, I’d like to use USB Wi-Fi.

(networking.networkmanager.enabled is enabled)

I tried several USB WiFi sticks that I have but nothing worked so I’m assuming NixOS doesn’t have the kernel modules that for example Ubuntu in default installation has.

I found option:

boot.kernelModules

But I’m not sure if I should use it for something that should be loadable. In other words I don’t think I should see the modules in lsmod before I actually stick the USB Wi-Fi in.

Could you please advise what to do?

Also do you have names of common Wi-Fi kernel modules I could add?

Thank you.

Martin

Check lspci (onboard) and lsusb (usb) output for the name and vid/pid of your WiFi adapters. Then use that to figure out what drivers you need - or why they aren’t loaded.

Post the output of those commands if you can’t find the right driver yourself.

Forcibly loading random WiFi modules is of little use (they should be automatically loaded).

That’s something that is definitely true on a traditional distribution but is that true on NixOS?

My assumption is that things missing in configuration (all config, including the generated hardware config) are simply not present and therefore can’t be loaded.

I (just for testing) added this:

boot.kernelModules = [
"brcmfmac"
"brcmutil"
"iwlmvm"
"iwlwifi"
"mmc_core"
"mt76_usb"
"mt76"
"mt76x0_common"
"mt76x02_lib"
"mt76x02_usb"
"mt76x0u"
"r8188eu"
"rtl_usb"
"rtl8192c_common"
"rtl8192cu"
"rtlwifi"
]

And the following:

Bus 001 Device 002: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]

started working.

The PCI Wi-Fi that doesn’t work is:

00:14.3 Network controller: Intel Corporation Device 7a70 (rev 11)

lspci -s 00:14.3 -k
00:14.3 Network controller: Intel Corporation Device 7a70 (rev 11)
        Subsystem: Intel Corporation Device 0094
        Kernel modules: iwlwifi

And search engine tells me that this is: Intel® Wi-Fi 6 AX201

That USB adapter requires rtl8192cu. The Intel card works with iwlwifi (it’s loaded, too!).

As for the USB adapter: that driver should be automatically loaded by systemd-udevd when you plug it in. Adding it to boot.kernelModules probably forces a modprobe, but that shouldn’t be necessary.

For PCI: the driver is loaded and bound to the PCI device, so it should show up in ip link. Is there anything interesting in dmesg related to iwlwifi?

Thank you @ius for the answer.

Yes

Jun 30 07:39:35 nixos kernel: iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-39.ucode failed with error -2
Jun 30 07:39:35 nixos kernel: iwlwifi 0000:00:14.3: no suitable firmware found!
Jun 30 07:39:35 nixos kernel: iwlwifi 0000:00:14.3: minimum version required: iwlwifi-so-a0-gf-a0-39
Jun 30 07:39:35 nixos kernel: iwlwifi 0000:00:14.3: maximum version supported: iwlwifi-so-a0-gf-a0-72
Jun 30 07:39:35 nixos kernel: iwlwifi 0000:00:14.3: check git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git

I might need more current kernel since I’m running 6.1 (due ZFS issues in 6.2).

In other words Nix here works like as a normal distro - has all normal drivers / modules. Thank you.

Do you have the firmware installed? (hardware.enableRedistributableFirmware = true;)

1 Like

I do now and Wi-FI is working. You fixed my Wi-Fi. Youuuhuuu. Thank you very much!

Btw. could you please explain why there is no boot.availableKernelModules, just boot.kernelModules?. For sure there are some modules that are not in the kernel and based on you explanation boot.kernelModules is like running modprobe on each specified module.

Not entirely sure what you mean, but (nearly?) all modules part of Linux are present (i.e. available) by default.

If you meant to ask how to include out-of-tree kernel modules: there’s boot.extraModulePackages for that.

Thank you. I had a feeling that the kernel might be somehow skimmed down so people can be explicit what to add. In other words NixOS kernel is like traditional distro kernel. I’m slightly surprised since everything else in NixOS is just soooo different.

Thank you!