1{ stdenv, lib, fetchFromGitHub, kernel }:
2
3stdenv.mkDerivation rec {
4 pname = "r8125";
5 # On update please verify (using `diff -r`) that the source matches the
6 # realtek version.
7 version = "9.004.01";
8
9 # This is a mirror. The original website[1] doesn't allow non-interactive
10 # downloads, instead emailing you a download link.
11 # [1] https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software
12 src = fetchFromGitHub {
13 owner = "louistakepillz";
14 repo = "r8125";
15 rev = version;
16 sha256 = "0h2y4mzydhc7var5281bk2jj1knig6i64k11ii4b94az3g9dbq24";
17 };
18
19 hardeningDisable = [ "pic" ];
20
21 nativeBuildInputs = kernel.moduleBuildDependencies;
22
23 preBuild = ''
24 substituteInPlace src/Makefile --replace "BASEDIR :=" "BASEDIR ?="
25 substituteInPlace src/Makefile --replace "modules_install" "INSTALL_MOD_PATH=$out modules_install"
26 '';
27
28 makeFlags = [
29 "BASEDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}"
30 ];
31
32 buildFlags = [ "modules" ];
33
34 meta = with lib; {
35 homepage = "https://github.com/louistakepillz/r8125";
36 downloadPage = "https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software";
37 description = "Realtek r8125 driver";
38 longDescription = ''
39 A kernel module for Realtek 8125 2.5G network cards.
40 '';
41 # r8125 has been integrated into the kernel as of v5.9.1
42 broken = lib.versionAtLeast kernel.version "5.9.1";
43 license = licenses.gpl2Plus;
44 platforms = platforms.linux;
45 maintainers = with maintainers; [ peelz ];
46 };
47}