Getting RealTek 8852BE driver to work under NixOS

Hello! I’ve recently acquired a 4th gen ThinkPad E14 but have been struggling to get WiFi going… According to the spec-sheet, this laptop should have an RTL8852be chip.

Reading around that sounds like the rtw89 package is what I’m looking for but it’s complicated: the kernel module package seems to be broken. Moreover it seems that config.boot.kernelPackages.rtw89 is gone entirely?

hardware.firmware = [ pkgs.rtw89-firmware ];
boot.extraModulePackages = with config.boot.kernelPackages; [ rtw89 ];

leads to:

error: A definition for option `boot.extraModulePackages.[definition 1-entry 1]' is not of type `package'. Definition values:
       - In `/etc/nixos/configuration.nix': null

According to the post linked previously, on kernels later than 5.16 all I’d need is the rtw89-firmware package. That compiles but doesn’t seem to actually work.

I did some digging to figure out if these drivers would be what I needed. I ended up running Ubuntu (kernel 5.15, does that matter? :/) from a USB-stick and installed the rtw8852be drivers from GitHub, and it worked! (although pinging 8.8.8.8 gave me repeatedly high latency spikes, maybe NetworkManager, maybe this chip is rubbish?). According to a recent commit in that codebase, this driver has been included in the rtw89 repo. However, building and activating module rtw_8852be built from this repo did not work!

So far I’ve tried copying and adjusting the derivation for rtw89, hoping that swapping the GitHub repo for the rtw8852be one would do the trick. No luck so far :slight_smile:

Any pointers on how to further debug this would be grand! Is it possible to build this module locally like I would on another distro and test if it works, then try to package it in a derivation?

Thanks for reading!
Kirth

I’m not super familiar with realteks naming scheme, but wouldn’t the rtw88 package be more of what you’re looking for?

Nevermind, there’s no 8852be:

$ nix-build -A linuxPackages.rtw88
$ cat ./result/lib/modules/5.15.74/kernel/drivers/net/wireless/realtek/rtw88/rtw_
rtw_8723de.ko.xz  rtw_8723d.ko.xz   rtw_8821ce.ko.xz  rtw_8821c.ko.xz   rtw_8822be.ko.xz  rtw_8822b.ko.xz   rtw_8822ce.ko.xz  rtw_8822c.ko.xz   rtw_core.ko.xz    rtw_pci.ko.xz

A PR will probably need to add support for the chipset.

Hey Jon, thank you for your response; the naming is indeed confusing! Could you show me how you got to those .ko files? I’m still trying to compile these in a derivation but not much luck so far…

Here’s a gist with what I have so far. Is there a better way to test this “build” without running nixos-rebuild switch? How can I load this file into a nix-shell? And how should I wrap the make invocation to know the correct path to the kernel headers/libs for building, is setting makeFlags alone not enough?

Is there a way for me to build this module manually outside of nix to test if it works reliably? (wifi latency and throughput)

Thanks!

Could you show me how you got to those .ko files?

Updated comment

Here’s a gist with what I have so far

You probably need to change modDestDir to have rtl8852be as the directory

And how should I wrap the make invocation to know the correct path to the kernel headers/libs for building, is setting makeFlags alone not enough?

Should be

Is there a better way to test this “build” without running nixos-rebuild switch ?

Don’t think so. If you want to test if wifi works

For iterating on NixOS configurations, I usually do a workflow like this: https://www.youtube.com/watch?v=bkDYmvKINm8

Follow-up: I got this driver GitHub - lwfinger/rtw8852be: Linux driver for RTW8852BE PCIe card to work under Arch; the dkms driver in the readme did not work. Unfortunately I couldn’t figure out how to shove this in a derivation. I ended up buying an Intel AX210 for 30 euros and transplanted it in: works flawlessly :).

Thank you for reading, I hope you have better luck!

For anyone stumbling upon this issue for other Realtek devices:

My wifi card is Realtek RTW8852CE which used to work with Nixos 6.9, but stopped working with Linux kernel 6.10. The driver is part of GitHub - lwfinger/rtw89: Driver for Realtek 8852AE, an 802.11ax device and also available upstream in the mainline kernel, but it is’t loaded automatically anymore.

I had to lsmod | grep rtw to find the module name on my Nixos 6.9 generation and manually add it to kernelModules for 6.10:

 boot.kernelModules = [
   # get wifi drivers to work for Realtek Wifi RTL8852CE
   "rtw89_8852ce"
 ];

edit:
Don’t upgrade to the new kernel 6.11 release or newer 6.10 point releases as the Realtek Wifi driver broke for some models on certain mainboard. A fix in progress:
https://bbs.archlinux.org/viewtopic.php?id=299462

1 Like