From a7b77a4555ff6719a3abb9116cbb4a3a0b52e612 Mon Sep 17 00:00:00 2001 From: Bart van der Braak Date: Sat, 26 Oct 2024 15:06:17 +0200 Subject: [PATCH] Add fixes --- tongfang/nixos/hardware-configuration.nix | 2 +- .../{yt6801-driver.nix => yt6801/default.nix} | 16 +++++------- tongfang/nixos/yt6801/src_makefiles.patch | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) rename tongfang/nixos/{yt6801-driver.nix => yt6801/default.nix} (76%) create mode 100644 tongfang/nixos/yt6801/src_makefiles.patch diff --git a/tongfang/nixos/hardware-configuration.nix b/tongfang/nixos/hardware-configuration.nix index b210710..9ead310 100644 --- a/tongfang/nixos/hardware-configuration.nix +++ b/tongfang/nixos/hardware-configuration.nix @@ -4,7 +4,7 @@ { config, lib, pkgs, modulesPath, ... }: let - yt6801 = import ./yt6801-driver.nix { + yt6801 = import ./yt6801/default.nix { inherit (pkgs) lib stdenv fetchzip nukeReferences bc; kernel = pkgs.linuxPackages.kernel; }; diff --git a/tongfang/nixos/yt6801-driver.nix b/tongfang/nixos/yt6801/default.nix similarity index 76% rename from tongfang/nixos/yt6801-driver.nix rename to tongfang/nixos/yt6801/default.nix index 493a1d2..a22b645 100644 --- a/tongfang/nixos/yt6801-driver.nix +++ b/tongfang/nixos/yt6801/default.nix @@ -6,27 +6,23 @@ stdenv.mkDerivation rec { name = "${pname}-${version}-${kernel.version}"; src = fetchzip { - url = "https://www.motor-comm.com/Public/Uploads/uploadfile/files/20240812/yt6801-linux-driver-1.0.29.zip"; + url = "https://www.motor-comm.com/Public/Uploads/uploadfile/files/20240812/yt6801-linux-driver-${version}.zip"; sha256 = "sha256-oz6CeOUN6QWKXxe3WUZljhGDTFArsknjzBuQ4IchGeU="; stripRoot = false; }; + patches = [ "./src_makefile.patch" ]; + hardeningDisable = [ "pic" "format" ]; KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}"; nativeBuildInputs = [ bc ] ++ kernel.moduleBuildDependencies; - preBuild = '' - cd src - ''; + preBuild = "cd src"; buildFlags = [ "modules" ]; patchPhase = '' substituteInPlace ./src/Makefile \ - --replace-fail 'KSRC_BASE = /lib/modules/$(shell uname -r)' "KSRC_BASE = ${KERNELDIR}" \ - --replace-fail 'sudo ls -l $(ko_dir)' "" \ - --replace-fail 'depmod $(shell uname -r)' "" \ - --replace-fail 'modprobe $(KFILE)' "" \ - --replace-fail '@modinfo $(ko_full)' "" + --replace-fail 'KSRC_BASE = /lib/modules/$(shell uname -r)' "KSRC_BASE = ${KERNELDIR}" ''; makeFlags = [ "ARCH=${stdenv.hostPlatform.linuxArch}" @@ -39,7 +35,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Motorcomm yt6801 Network Interface Card (NIC) driver"; - homepage = "https://www.motor-comm.com/"; + homepage = "https://www.motor-comm.com/product/ethernet-control-chip"; license = licenses.gpl2Only; platforms = platforms.linux; maintainers = with maintainers; [ bartvdbraak ]; diff --git a/tongfang/nixos/yt6801/src_makefiles.patch b/tongfang/nixos/yt6801/src_makefiles.patch new file mode 100644 index 0000000..97e7a67 --- /dev/null +++ b/tongfang/nixos/yt6801/src_makefiles.patch @@ -0,0 +1,25 @@ +diff --git a/src/Makefile b/src/Makefile +index 9b29b47..552558e 100755 +--- a/src/Makefile ++++ b/src/Makefile +@@ -32,20 +32,10 @@ modules: + make -C $(KSRC) M=$(PWD) modules + + install: +- @echo "KFILE: " $(KFILE) +- @echo "KDST: " $(KDST) + make -C $(KSRC) M=$(PWD) INSTALL_MOD_DIR=$(KDST) modules_install +- sudo ls -l $(ko_dir) +- depmod $(shell uname -r) +- modprobe $(KFILE) +- @file $(ko_full) +- @echo install done. +- @modinfo $(ko_full) + + uninstall: +- sudo ls -l $(ko_dir) + sudo rm $(ko_full) +- sudo ls -l $(ko_dir) + + clean: + make -C $(KSRC) M=$(PWD) clean