1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 kernel,
6}:
7
8stdenv.mkDerivation rec {
9 pname = "ch9344";
10 version = "2.3";
11
12 src = fetchFromGitHub {
13 owner = "WCHSoftGroup";
14 repo = "ch9344ser_linux";
15 rev = "e0a38c4f4f9d4c1f5e2e3a352b7b1010b33aa322";
16 hash = "sha256-ldYoGmG9DAjASl3xL8djeZ8jRHlcBQdAt0KYAr53epI=";
17 };
18
19 patches = [
20 ./fix-linux-6-12-build.patch
21 ./fix-linux-6-15-build.patch
22 ];
23
24 sourceRoot = "${src.name}/driver";
25 hardeningDisable = [ "pic" ];
26 nativeBuildInputs = kernel.moduleBuildDependencies;
27
28 preBuild = ''
29 substituteInPlace Makefile --replace "KERNELDIR :=" "KERNELDIR ?="
30 '';
31
32 makeFlags = [
33 "KERNELDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
34 ];
35
36 installPhase = ''
37 runHook preInstall
38 install -D ch9344.ko $out/lib/modules/${kernel.modDirVersion}/usb/serial/ch9344.ko
39 runHook postInstall
40 '';
41
42 meta = with lib; {
43 homepage = "https://www.wch-ic.com/";
44 downloadPage = "https://github.com/WCHSoftGroup/ch9344ser_linux";
45 description = "WCH CH9344/CH348 UART driver";
46 longDescription = ''
47 A kernel module for WinChipHead CH9344/CH348 USB To Multi Serial Ports controller.
48 '';
49 license = licenses.gpl2Only;
50 platforms = platforms.linux;
51 maintainers = with maintainers; [ RadxaYuntian ];
52 };
53}