1{ stdenv, lib, fetchFromGitHub, kernel, fetchurl, fetchpatch }:
2
3stdenv.mkDerivation rec {
4 pname = "xone";
5 version = "0.3";
6
7 src = fetchFromGitHub {
8 owner = "medusalix";
9 repo = pname;
10 rev = "refs/tags/v${version}";
11 sha256 = "sha256-h+j4xCV9R6hp9trsv1NByh9m0UBafOz42ZuYUjclILE=";
12 };
13
14 patches = [
15 # Fix build on kernel 6.3
16 (fetchpatch {
17 name = "kernel-6.3.patch";
18 url = "https://github.com/medusalix/xone/commit/bbf0dcc484c3f5611f4e375da43e0e0ef08f3d18.patch";
19 hash = "sha256-A2OzRRk4XT++rS6k6EIyiPy/LJptvVRUxoP7CIGrPWU=";
20 })
21 ];
22
23 setSourceRoot = ''
24 export sourceRoot=$(pwd)/${src.name}
25 '';
26
27 nativeBuildInputs = kernel.moduleBuildDependencies;
28
29 makeFlags = [
30 "-C"
31 "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
32 "M=$(sourceRoot)"
33 "VERSION=${version}"
34 ];
35
36 buildFlags = [ "modules" ];
37 installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ];
38 installTargets = [ "modules_install" ];
39
40 meta = with lib; {
41 description = "Linux kernel driver for Xbox One and Xbox Series X|S accessories";
42 homepage = "https://github.com/medusalix/xone";
43 license = licenses.gpl2;
44 maintainers = with lib.maintainers; [ rhysmdnz ];
45 platforms = platforms.linux;
46 };
47}
48