1 # Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
3 pkgname=(nvidia-open nvidia-open-dkms)
6 pkgdesc="NVIDIA open kernel modules"
8 url="https://github.com/NVIDIA/open-gpu-kernel-modules"
9 depends=("nvidia-utils=${pkgver}" 'libglvnd')
10 makedepends=('linux-headers')
12 options=('!lto' '!buildflags')
13 source=("$pkgname-$pkgver.tar.gz::https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${pkgver}.tar.gz"
14 nvidia-open-gcc-ibt-sls.patch)
15 sha512sums=('c2ff6fd02272b6981a65e7e14c6b636f0113e21da910898c27682f58e60fa8e6deea3670081c57e4961fb5e7794eef8eddb90d134ba1892536a8468c5dc9d669'
16 'a8821f36c7515bfe4f50d7e3d15a6a8464ec833ca19818d674e300199f3867971f6fba35e1a357fa8ced08cc91d36c2f7fb37cb247bcbf18fa706f97916639b5')
19 cd open-gpu-kernel-modules-${pkgver}
21 # Fix for https://bugs.archlinux.org/task/74886
22 patch -Np1 --no-backup-if-mismatch -i "$srcdir"/nvidia-open-gcc-ibt-sls.patch
24 # Attempt to make this reproducible
25 sed -i "s/^HOSTNAME.*/HOSTNAME = echo archlinux"/ utils.mk
26 sed -i "s/^WHOAMI.*/WHOAMI = echo archlinux-builder"/ utils.mk
27 sed -i "s/^DATE.*/DATE = date -r version.mk"/ utils.mk
29 sed -i "s/__VERSION_STRING/${pkgver}/" kernel-open/dkms.conf
30 sed -i 's/__JOBS/`nproc`/' kernel-open/dkms.conf
31 sed -i 's/__EXCLUDE_MODULES//' kernel-open/dkms.conf
32 sed -i 's/__DKMS_MODULES//' kernel-open/dkms.conf
34 BUILT_MODULE_NAME[0]="nvidia"\
35 BUILT_MODULE_LOCATION[0]="kernel-open"\
36 DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
37 BUILT_MODULE_NAME[1]="nvidia-uvm"\
38 BUILT_MODULE_LOCATION[1]="kernel-open"\
39 DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
40 BUILT_MODULE_NAME[2]="nvidia-modeset"\
41 BUILT_MODULE_LOCATION[2]="kernel-open"\
42 DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
43 BUILT_MODULE_NAME[3]="nvidia-drm"\
44 BUILT_MODULE_LOCATION[3]="kernel-open"\
45 DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
46 BUILT_MODULE_NAME[4]="nvidia-peermem"\
47 BUILT_MODULE_LOCATION[4]="kernel-open"\
48 DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' kernel-open/dkms.conf
50 # Clean version for later copying for DKMS
51 cp -r ../open-gpu-kernel-modules-${pkgver} "$srcdir"/open-gpu-kernel-modules-dkms
55 cd open-gpu-kernel-modules-${pkgver}
56 make SYSSRC="/usr/src/linux"
59 package_nvidia-open() {
61 conflicts=('NVIDIA-MODULE')
62 provides=('NVIDIA-MODULE')
64 cd open-gpu-kernel-modules-${pkgver}
65 _extradir="/usr/lib/modules/$(</usr/src/linux/version)/extramodules"
66 install -Dt "${pkgdir}${_extradir}" -m644 kernel-open/*.ko
67 find "${pkgdir}" -name '*.ko' -exec strip --strip-debug {} +
68 find "${pkgdir}" -name '*.ko' -exec xz {} +
70 # Force module to load even on unsupported GPUs
71 mkdir -p "$pkgdir"/usr/lib/modprobe.d
72 echo "options nvidia NVreg_OpenRmEnableUnsupportedGpus=1" > "$pkgdir"/usr/lib/modprobe.d/nvidia-open.conf
74 install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname
77 package_nvidia-open-dkms() {
79 conflicts=('nvidia-open' 'NVIDIA-MODULE')
80 provides=('nvidia-open' 'NVIDIA-MODULE')
82 install -dm 755 "${pkgdir}"/usr/src
83 # cp -dr --no-preserve='ownership' kernel-open "${pkgdir}/usr/src/nvidia-$pkgver"
84 cp -dr --no-preserve='ownership' open-gpu-kernel-modules-dkms "${pkgdir}/usr/src/nvidia-$pkgver"
85 mv "${pkgdir}/usr/src/nvidia-$pkgver/kernel-open/dkms.conf" "${pkgdir}/usr/src/nvidia-$pkgver/dkms.conf"
87 # Force module to load even on unsupported GPUs
88 mkdir -p "$pkgdir"/usr/lib/modprobe.d
89 echo "options nvidia NVreg_OpenRmEnableUnsupportedGpus=1" > "$pkgdir"/usr/lib/modprobe.d/nvidia-open.conf
91 install -Dm644 open-gpu-kernel-modules-${pkgver}/COPYING "$pkgdir"/usr/share/licenses/$pkgname