Trouble enabling the `btqca` driver module in the linux kernel using `kernelPatches`

Context

I’m attempting to include the btqca driver module in my linux build via nix configuration in order to enable bluetooth on my XPS 13 9310. You can find the module in question within the linux src here.

It appears the module is not included by default, as nothing shows up when running:

lsmod | grep -i qca

Adding btqca

thibm gave me a hint on Matrix, mentioning:

…you need to compile the module or compile the kernel with the custom configuration BT_QCA=y or BT_QCA=m

To achieve this, I tried adding the following to my nix config:

  # Enable the `btqca` module in the linux kernel.
  boot.kernelPatches = [
    {
      name = "enable-qca6390-bluetooth";
      patch = null;
      extraConfig = ''
        BT_QCA=y
      '';
    }
  ];

  # Enable the bluetooth driver for the QCA6390.
  boot.kernelModules = [ "btqca" ];

And then running sudo nixos-rebuild build. The kernel build process failed mentioning that BT_QCA=y was invalid syntax, so I tried changing it to BT_QCA y. The build progressed further but failed again, this time with a different error.

The Error

error: unused option: BT_QCA

I’ve been searching around trying to work out why this might be the case, but haven’t been able to find any leads just yet. I also tried CONFIG_BT_QCA and HCI_QCA but each produced the same unused option error above.

Any ideas or guidance would be greatly appreciated!

Extra info

Fwiw, I’m using linuxPackages_testing via the nixos-unstable channel, and the version of Linux being built is 5.10-rc5.

This is one step in my saga of adding a nix expr for Dell XPS 13 9310 support to the nixos-hardware repo, which you can follow along with here.

Edit: I get the same error when attempting to build the kernel with buildLinux pointing to a local clone of the 5.10-rc4 branch, where I can see the btqca src is included.

Ahh, it seems this error is due to the fact that BT_QCA is not expected to be used in isolation - rather it is to be used via BT_HCIUART_QCA. Updating the config with the following seems to be progressing a lot further.

      extraConfig = ''
        BT_QCA m
        BT_HCIUART m
        BT_HCIUART_QCA y
      '';

Not 100% sure if the BT_HCIUART m line is necessary yet or if its included implicitly via BT_HCIUART_QCA y.

See this GitHub comment for a little background on how I came across these config lines.