Custom kernel module ending up in the wrong place

I have set up a device with this hardware-configuration.nix, which is imported by configuration.nix, which is used in a flake (nixpkgs-unstable):

{ config, lib, pkgs, modulesPath, ... }:

let kernel = pkgs.linuxKernel.kernels.linux_6_1;

# ============== TOUCHSCREEN ================
 gslx680-acpi = with pkgs; stdenv.mkDerivation rec {
  name = "gslx680-acpi";
  version = "v0.2.2";

  src = fetchFromGitHub {
    owner = "onitake";
    repo = "gslx680-acpi";
    rev = "${version}";
    sha256 = "sha256-ZXnczstB5uFulVAMqT8Vmz5DtGCFPY0FkD61UKsiFg4=";

  makeFlags = [

  patches = [ ./gslx680-acpi-makefile.patch ];

  nativeBuildInputs = kernel.moduleBuildDependencies;

# ============== BLUETOOTH ================

  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")

  hardware.firmware = [
        gsl-firmware = pkgs.fetchFromGitHub {
          owner = "onitake";
          repo = "gsl-firmware";
          rev = "master";
          sha256 = "sha256-S5Bxun9167+Iu+VHY4+XzvedTIkpLsCLMiQpR7twTNY=";
      pkgs.runCommandNoCC "gsl-firmware" { } ''
        mkdir -p $out/lib/firmware/silead
        cp ${gsl-firmware}/firmware/chuwi/hi8/firmware.fw $out/lib/firmware/silead/gsl1680-chuwi-hi8.fw

  boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" "sd_mod" "sdhci_acpi" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" "gslx680-acpi" ];
  boot.extraModulePackages = [ gslx680-acpi ];
  boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_1;
  networking.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; = lib.mkDefault config.hardware.enableRedistributableFirmware;

I was trying to first load the out-of-tree kernel module from, and then copy the file from GitHub - onitake/gsl-firmware: Firmware repository for Silead touchscreen controllers (path: /firmware/chuwi/hi8/firmware.fw) to /lib/firmware/silead/gsl1680-chuwi-hi8.fw (That’s where the module on debian was searching for it, maybe nixos has a different place for it. idk)

It doesn’t work for some reason. The kernel module does not appear in /sys/modules and /lib/firmware doesn’t exist.

Can you help me?

UPDATE: for some reason there is gslx680_ts_acpi.ko in /run/booted-system/kernel-modules
I have tried to put it in /lib/<...>, but nothing changed

1 Like

Does the module appear under your generation’s kernel-modules/ directory (i.e. /run/booted-system/kernel-modules/lib/modules/kernelModVersionHere/updates/)?

Are you able to modprobe/insmod it?

No, the module isn’t there and modprobe fails. but for some reason there is gslx680_ts_acpi.ko in /run/booted-system/kernel-modules

I’d take a closer look at the output path which your custom module drv actually produces.

The resulting derivation just contains gslx680_ts_acpi.ko. I have tried to put it in /lib/<...>, but nothing changed

How do the already packaged kernel modules deal with this?

I am dealing with the same issue and have been documenting my attempts here

That’s wrong, it must be in the kernel-ABI specific lib dir for it to work with NixOS options.

What happens when you insmod that file?

Are you sure you put it into the correct directory? It must be




Check the source. I.e. nixpkgs/pkgs/os-specific/linux/nct6687d/default.nix at 213b7c561bdd292f11ff99373222c2545c53ce7a · NixOS/nixpkgs · GitHub

How and where the module file is installed however is defined by the package’s build system however. That’s what you need to consult. You may need to set a specific installTarget like I had to in the module above.