OpenRGB kernel patch with options

I am trying to setup OpenRGB in my NixOS 23.11. However when I decided to run OpenRGB, it can not scan most RGB devices. It does not work at all.
I am following OpenRGB readme, it also suggests to patch the kernel and enable i2c-nct6775. Direct instructions here.

Honestly it seems a lot of hassale to build a kernel manually.

What would be the nix way of doing this?

I am using the following configuration.

  # OpenRGB setup
  services.hardware.openrgb = {
    enable = true;
    motherboard = "amd";
    package = pkgs.openrgb-with-all-plugins; # enable all plugins
  environment.systemPackages = [ pkgs.i2c-tools ];
  users.groups.i2c.members = [ "username" ]; # create i2c group and add default user to it

This is the issue if I try to manually rescan.

You can apply the patches with boot.kernelPatches.

Changing the kernel config is a little more annoying, you’ll have to override the kernel package to do that, but is otherwise not difficult: NixOS 23.11 manual | Nix & NixOS

Maybe you’re lucky and i2c-nct6775 is enabled by default, or a module, so you can just apply the patches.

1 Like

Override the kernel package, the thing is I have no idea how to do that and what options there are.
It’s not as simple as make menuconfig. Can you please provide an example?

Well, that’s why I linked the nixpkgs manual chapter on the Linux kernel, it has an example:

nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs {
  linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {
    extraConfig = ''
      KGDB y

That is to enable the KGDB option, of course, not what you want.

If you’re trying to enable an option that someone else has only given you by menuconfig comment you’ll either need to find out what the corresponding option name is via some clever internet searching, or use menuconfig to convert the comment to a name.

The latter might be easier if you can be bothered to put a bit of effort in, just clone the kernel as you would normally, make menuconfig to create a config without the desired option, copy the .config to something like .config.bak, then make another config exactly the same but enable the option this time.

diff .config.bak .config will then give you the right option name. The rest is just throwing it at nix.

You can also see the current kernel config with zcat /proc/config.gz, just as the nixpkgs manual says, which will probably contain the option you’re looking for, some educated grepping of that file can go a long way.

If you want to get nix to clone the kernel for you, I think you can do that with nix develop --unpack nixpkgs#linuxKernel.kernels.<your kernel>.

Thanks! the relevant option is: CONFIG_I2C_NCT6775=y
The patch does not need to be applied manually if zen-kernel is used, which automatically includes this patch.

  boot.kernelPatches = [
      name = "NCT6775 driver";
      patch = null; # no patch needed if zen-kernel is enabled
      extraStructuredConfig = with lib.kernel; {
        I2C_NCT6775 = lib.mkForce yes;

From the manual:

The name of the option should not include the prefix CONFIG_.

Edit: Ah, you spotted it :slight_smile:

1 Like

Yep, thanks! See you in an hour!

1 Like

By the way, does extraStructuredConfig support integer values for config options?
I wanna set maximum threads support to 20 (I am customizing my kernel)
NR_CPUS = 20 does not really work.

Don’t know! Presumably, yes, but I’ve never used that interface myself. You could check the implementation, that often helps with this kind of problem.