aux: replace garbage r8169 driver from mainline kernel

This commit is contained in:
Sebastien Bourdeauducq 2022-09-23 09:55:32 +08:00
parent e2e4b0842a
commit 97ba57fbcd
3 changed files with 45 additions and 0 deletions

View File

@ -15,6 +15,9 @@ in
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/sda";
boot.blacklistedKernelModules = [ "r8169" ];
boot.extraModulePackages = [ (pkgs.callPackage ./r8169 { kernel = config.boot.kernelPackages.kernel; }) ];
networking.hostName = "aux";
networking.interfaces."${netifWan}".useDHCP = true;

View File

@ -0,0 +1,42 @@
{ stdenv, lib, kernel }:
let modDestDir = "$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/net/wireless/realtek/r8169";
in stdenv.mkDerivation rec {
name = "r8169-${kernel.version}-${version}";
version = "6.030.01";
src = ./r8169-${version}.tar.bz2;
hardeningDisable = [ "pic" ];
nativeBuildInputs = kernel.moduleBuildDependencies;
# rename to avoid conflict with totally broken piece of crap from mainline kernel
patchPhase =
''
substituteInPlace src/Makefile --replace r8169.o r8169-vendor.o
substituteInPlace src/Makefile --replace r8169-objs r8169-vendor-objs
'';
# avoid using the Makefile directly -- it doesn't understand
# any kernel but the current.
# based on the ArchLinux pkgbuild: https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/r8168
makeFlags = kernel.makeFlags ++ [
"-C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"M=$(PWD)/src"
"modules"
];
preBuild = ''
makeFlagsArray+=("EXTRA_CFLAGS=-DCONFIG_R8169_NAPI -DCONFIG_R8169_VLAN -DCONFIG_ASPM -DENABLE_S5WOL -DENABLE_EEE")
'';
enableParallelBuilding = true;
installPhase = ''
mkdir -p ${modDestDir}
find . -name '*.ko' -exec cp --parents '{}' ${modDestDir} \;
find ${modDestDir} -name '*.ko' -exec xz -f '{}' \;
'';
}

Binary file not shown.