1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 kernel,
6 kernelModuleMakeFlags,
7 nvidia_x11,
8 hash,
9 patches ? [ ],
10 broken ? false,
11}:
12
13stdenv.mkDerivation (
14 {
15 pname = "nvidia-open";
16 version = "${kernel.version}-${nvidia_x11.version}";
17
18 src = fetchFromGitHub {
19 owner = "NVIDIA";
20 repo = "open-gpu-kernel-modules";
21 rev = nvidia_x11.version;
22 inherit hash;
23 };
24
25 inherit patches;
26
27 nativeBuildInputs = kernel.moduleBuildDependencies;
28
29 makeFlags = kernelModuleMakeFlags ++ [
30 "SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
31 "SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
32 "MODLIB=$(out)/lib/modules/${kernel.modDirVersion}"
33 "DATE="
34 {
35 aarch64-linux = "TARGET_ARCH=aarch64";
36 x86_64-linux = "TARGET_ARCH=x86_64";
37 }
38 .${stdenv.hostPlatform.system}
39 ];
40
41 installTargets = [ "modules_install" ];
42 enableParallelBuilding = true;
43
44 meta = with lib; {
45 description = "NVIDIA Linux Open GPU Kernel Module";
46 homepage = "https://github.com/NVIDIA/open-gpu-kernel-modules";
47 license = with licenses; [
48 gpl2Plus
49 mit
50 ];
51 platforms = [
52 "x86_64-linux"
53 "aarch64-linux"
54 ];
55 maintainers = with maintainers; [ nickcao ];
56 inherit broken;
57 };
58 }
59 // lib.optionalAttrs stdenv.hostPlatform.isAarch64 {
60 env.NIX_CFLAGS_COMPILE = "-fno-stack-protector";
61 }
62)