Override Kernel Packages (new-lg4ff, universal-pidff)

Hi there,

I have a Logitech steering wheel and I used it with Oversteer and new-lg4ff. There is an option in NixOS called hardware.new-lg4ff which enables the module. When I switched to a newer Linux Kernel I get a build error which is fixed in the Git repo. My question now is how can I override the new-lg4ff module? I copied the package definition from the nixpkgs repository and changed the src like this

{
  pkgs,
  lib,
  stdenv,
  kernel ? pkgs.linuxPackages_latest.kernel,
  fetchFromGitHub,
}:

stdenv.mkDerivation {
  pname = "new-lg4ff";
  version = "latest";

  src = fetchFromGitHub {
      owner = "berarma";
      repo = "new-lg4ff";
      rev = "master";
      sha256 = "sha256-90PnQDGwp94ELvWx6p8QiZucYmTbH3N0GiZbj3fo25g=";
    };

  preBuild = ''
    substituteInPlace Makefile --replace "modules_install" "INSTALL_MOD_PATH=$out modules_install"
    sed -i '/depmod/d' Makefile
    sed -i "10i\\\trmmod hid-logitech 2> /dev/null || true" Makefile
    sed -i "11i\\\trmmod hid-logitech-new 2> /dev/null || true" Makefile
  '';

  nativeBuildInputs = kernel.moduleBuildDependencies;

  makeFlags = [
    "KVERSION=${kernel.modDirVersion}"
    "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
  ];

  meta = with lib; {
    description = "Experimental Logitech force feedback module for Linux";
    homepage = "https://github.com/berarma/new-lg4ff";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ matthiasbenaets ];
    platforms = platforms.linux;
    broken = stdenv.hostPlatform.isAarch64;
  };
}

Then I tried using https://nixos.wiki/wiki/Linux_kernel#Overriding_kernel_packages with

 nixpkgs.overlays = [
    (self: super: {
      linuxPackages = super.linuxPackages.extend (lpself: lpsuper: {
        new-lg4ff = super.linuxPackages.new-lg4ff.overrideAttrs (oldAttrs: {
            src = fetchFromGitHub {
              owner = "berarma";
              repo = "new-lg4ff";
              rev = "master";
              sha256 = "sha256-90PnQDGwp94ELvWx6p8QiZucYmTbH3N0GiZbj3fo25g=";
           };
        });
      });
    })
  ];

But I’m still getting the same build error. Has someone an idea what I could try to make this work?

Thank you :slight_smile: