Add out-of-tree kernel module for Motorcomm yt6801 Network Interface Card (NIC) driver (#7)

* Add initial test to run with the new driver install

* Fix unpacking by using git source

* Change buildinputs and patch commands

* Working example of extra yt6801 module

* Add fixes

* Consolidate changes
This commit is contained in:
Bart van der Braak 2024-10-26 17:05:52 +02:00 committed by GitHub
parent ecfb278d2a
commit 6cbbb95810
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 1 deletions

View file

@ -3,6 +3,12 @@
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: { config, lib, pkgs, modulesPath, ... }:
let
yt6801 = import ./yt6801/default.nix {
inherit (pkgs) lib stdenv fetchFromGitHub nukeReferences bc;
kernel = pkgs.linuxPackages.kernel;
};
in
{ {
imports = imports =
[ (modulesPath + "/installer/scan/not-detected.nix") [ (modulesPath + "/installer/scan/not-detected.nix")
@ -11,7 +17,7 @@
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" "sdhci_pci" ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ yt6801 ];
fileSystems."/" = fileSystems."/" =
{ device = "/dev/disk/by-uuid/c7cf28c3-5744-45cc-8a81-456d24e44b7a"; { device = "/dev/disk/by-uuid/c7cf28c3-5744-45cc-8a81-456d24e44b7a";

View file

@ -0,0 +1,43 @@
{ lib, stdenv, fetchFromGitHub, nukeReferences, bc, kernel }:
stdenv.mkDerivation rec {
pname = "yt6801";
version = "1.0.29";
name = "${pname}-${version}-${kernel.version}";
src = fetchFromGitHub {
owner = "bartvdbraak";
repo = pname;
rev = version;
sha256 = "sha256-VEBwcbJcLffIIAP+NIhjiuMkfR+PKybBDnIbxY6zBMA=";
};
patchPhase = ''
substituteInPlace ./src/Makefile \
--replace-fail 'KSRC_BASE = /lib/modules/$(shell uname -r)' "KSRC_BASE = ${KERNELDIR}"
'';
hardeningDisable = [ "pic" "format" ];
KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}";
nativeBuildInputs = [ bc ] ++ kernel.moduleBuildDependencies;
preBuild = "cd src";
buildFlags = [ "modules" ];
makeFlags = [
"ARCH=${stdenv.hostPlatform.linuxArch}"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ];
enableParallelBuilding = true;
meta = with lib; {
description = "Motorcomm yt6801 Network Interface Card (NIC) driver";
homepage = "https://www.motor-comm.com/product/ethernet-control-chip";
license = licenses.gpl2Only;
platforms = platforms.linux;
maintainers = with maintainers; [ bartvdbraak ];
};
}