summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIonen Wolkens <ionen@gentoo.org>2022-05-11 17:30:09 -0400
committerIonen Wolkens <ionen@gentoo.org>2022-05-11 17:50:45 -0400
commitba623145fa97e7b208fdd831841cb2376dbfc7e7 (patch)
tree78519097f1d76d46f9566a26efebd97d742d72d7 /x11-drivers
parentx11-drivers/nvidia-drivers: drop 510.60.02 (diff)
downloadgentoo-ba623145fa97e7b208fdd831841cb2376dbfc7e7.tar.gz
gentoo-ba623145fa97e7b208fdd831841cb2376dbfc7e7.tar.bz2
gentoo-ba623145fa97e7b208fdd831841cb2376dbfc7e7.zip
x11-drivers/nvidia-drivers: add 515.43.04 unkeyworded (beta)
Opting to leave betas unkeyworded after all, feel free to test. - new IUSE=kernel-open to build open source variant, entirely untested (lacking a Turing / Ampere card). May or may not mask the USE entirely given how experimental it is, but given unkeyworded not worrying about this yet. - CONFIG_BACKLIGHT_CLASS_DEVICE conftest was removed and is used unconditionally, depend on it until further notice. Signed-off-by: Ionen Wolkens <ionen@gentoo.org>
Diffstat (limited to 'x11-drivers')
-rw-r--r--x11-drivers/nvidia-drivers/Manifest7
-rw-r--r--x11-drivers/nvidia-drivers/metadata.xml2
-rw-r--r--x11-drivers/nvidia-drivers/nvidia-drivers-515.43.04.ebuild474
3 files changed, 483 insertions, 0 deletions
diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest
index 1e1eed8566d6..2dda492175eb 100644
--- a/x11-drivers/nvidia-drivers/Manifest
+++ b/x11-drivers/nvidia-drivers/Manifest
@@ -1,21 +1,28 @@
DIST NVIDIA-Linux-aarch64-510.68.02.run 211263873 BLAKE2B 755a9e463af7eebce095d592fdb039a7178075aed9ff0d79658934f9269bb502185d7091a803dd0b0827c5d8a3e8d46e8a3e50646e39fedfa2b3ab9d580af6ed SHA512 b075e20b8457a1fe16a0ac1f34ff9a94d739673858a9a973c361856e07ab25a56e9ff2856a828866fea00407c5e4a4394d3c7aa6728a9a31bad0905e1d60f002
+DIST NVIDIA-Linux-aarch64-515.43.04.run 215715685 BLAKE2B 323b2c4bc5a40a3120af83397f675addd74a44d13179e7d3d080e278db2e9508e384f3e25203238bf833a670d9b08f41bec98bb43ad5fc5161c0edc826f06af0 SHA512 68a2018c1649558388a0e9dbef698cbd4ceb12fc651f618774d26c7cf1c2733450538c0b11fca0ca7c59a74089dab02a9cfb35e87b7b078cb8411f8835b7b1c2
DIST NVIDIA-Linux-x86-390.147.run 49303088 BLAKE2B 5a3a02b88af1ee8699b0c6c3fa222d9176338f10437a88c874126c7bacf64ddc44d03d8a44542cba989129af6336e46cae775713458a16d78ea75e4e004dfffb SHA512 c5d47e2a8c034e158093feeefa2455ec49d676fbd1700118aedba0c3b84be4e2060402d0e27e50d1a674de10f369f8e5ca2da8c61f1d0560d2105d33d7238359
DIST NVIDIA-Linux-x86_64-390.147.run 85930997 BLAKE2B a8085c9abc1c31251788a8f5abdc2090c9085b3028e364184244bbf24d822dc3266877c88b30f403507fa2dd511c68ec67e1f188d6b0f1f4d7d792881d5253fc SHA512 0d8bda32e916d71da2ea74bc12a4f3cb0a0c2ddda27511cf3c89bbf4aeb28db68f6b7261639d88dd1c0180b91213c09de930d233158268c5d9ab3b223510e964
DIST NVIDIA-Linux-x86_64-470.103.01.run 272484410 BLAKE2B 42a19ed990f49d4ceefc1006f3e6e4b69135ad2aaf497c648b9afe7941a81aba3a51296cb14bc419352cdf70f850484d2a55784184fdb820186193501422d742 SHA512 3dc19774a6fef5e6ec0cb9451df4268f77cb31b0a9ede253bf9cf805a048ad457a7bfec852aaeab3e3e297b3353840a3d6c9c7ddc75d57b2b000ab4e0b15530b
DIST NVIDIA-Linux-x86_64-470.62.29.run 271041614 BLAKE2B c49c1861e0ac1741e8e270d78327d75abd9c58fc06f23f4d8508976276afc69b9a83958ba855884767a82018b424bed9cf7b89c0514db56f55c2a3cff70d2d99 SHA512 bdd8dd25b2fa07c15a4e14bab9d7154f2be5c3d08960caf7d419247ff5d12c8366962346c2f38efee6daa935b020d8de09d9c145c08cdd0835a6fef0c2c3c76d
DIST NVIDIA-Linux-x86_64-510.68.02.run 329247384 BLAKE2B 44107d04df20533aa904146465d069ad30aa2aabc68c3588480d0c8e85e3e0eec7515d81bd411d63e02ee893343088e6805235386a8d3eb0f4cefb72083dc0ea SHA512 eb31ed729555075bcc307acc576cb6fdfdd7e397c9e47dd80fc2f55cac6902c3924b69bb91036e5ded1001e81d4b81082ba093dd63d6d97bc313fe78e510131b
+DIST NVIDIA-Linux-x86_64-515.43.04.run 358747732 BLAKE2B 295284c951deee77905a386e7c960c5ba715358ce47afa5f9bd03dfc3f14cc5aeb37dacf2d42f35a15ef3a48b59cf1bdc8a36074d48b06aa98112b60496dcdce SHA512 07dfcfc297d8dc3072ddf5d719ab5fe3de0aaa2d9b2b7329d86a1cc167c79bd3854c0644cc0080689e2529b3e375dc3ffb370afc3904362722b338d2c1c2837a
DIST nvidia-installer-390.147.tar.bz2 150157 BLAKE2B 3bf5317aaa3bdb0e6dc3b3e21ad3dbacf6dc782a643b0fa9badf354361891ab25660b57dd408e346f219d469af317a4851937e1cb77ffe59a39e9d98a92f3a40 SHA512 24bd8a2959062551abf2ea039ac95eba224d58c175f59f1386a6d43459ad43b2bddf17f00b53c1c71c45eca3b7a2281dcf05cc65030f6f8bed16d0f0b9f9c282
DIST nvidia-installer-470.103.01.tar.bz2 146121 BLAKE2B 06da3693cf8edba849b802f2255dcf2086ba3846f83ef19a02cb813ea2c07a6904f8a49e263018fb8b40c9fece7ab4422d95a50d12030ae6815ec60a7edac055 SHA512 b080f32394a6163c34e152561b80cca9277a53e0b38c5225b91daddc2169403e2ff4cf63a30b488ee0c3a954b21d32065b5624fb9dd33e672313909b9096de02
DIST nvidia-installer-510.68.02.tar.gz 199720 BLAKE2B 69f6514e5eac74897158585d90d215d689edce720257819af5b245768029efc9a95338b3aa3de1a63c8b107658375f248a688c31ea08513224e443083a5f68ce SHA512 24831d20f79bdd5e5d6c828f02d59f9c75b30169a46ac789615be5ae014c831fc5bcf267c5f5afa8fc84208eb427a9972638db0aca68510393916c041368ff45
+DIST nvidia-installer-515.43.04.tar.bz2 144712 BLAKE2B c83838cbd939c69859125306a20b6e05ba5f4db1e11e425a5a91ff28eb0aeaa5a6490b8927024c001e75efe59f0e0ac60b863fde76311afadd06335a466258e3 SHA512 3b0fff23b91e25ba1abf4be17affaf4e3c6e1da5420a73ccf8bfd38e01194ffbb22918a200d613217c1407c43460e9f9439697a70c2758b291a029a9a63d9bf9
DIST nvidia-modprobe-390.147.tar.bz2 35340 BLAKE2B acb49dea0c5d9d802b7c2f9f8127106bd6f9e2aaa7875941ca94c1d81377411e8d9c53357e7f9aa0170c87e349f6379a45391965e7897d0158951a4c0056a835 SHA512 a731fc990557f40fdd0fba45bcfeb99c315d0579a2d2f49bf6f84c55c91f52a9e65c358bc5a3882483ab8e9d66b546de31adcaba46a494bfc0836a0690c3d0db
DIST nvidia-modprobe-470.103.01.tar.bz2 38347 BLAKE2B bd86b8f76d040ea9bad06312b24d839413515c24867e88174d40e9dd0d9006d42fa57f8e789a8a0e8859dd1c1122ef6e57ea25fdda08eedcba10d9291181245c SHA512 ea86b083dd82ff7d8926d337f2aeccbd73cd614a85579cfcbb4ad7225565aa54f151e6d2b5d35b96eb413c3673158025348416193db5045809d743cc98d65281
DIST nvidia-modprobe-510.68.02.tar.gz 44311 BLAKE2B 83a50ba8d9f95864875548f1b0262065ca0a9b23eb1e9d3a5a0b7b1646efc7b12ca688874aad7cf61c291055d5e7a04894b91d27c246fa9e77946d110712575a SHA512 c2621d7125cc481b6850295c123ca354c9a37662c2611c1a52d6ee675a12bea619f64d7f3e12b52a7f36a4b8aa732b7e896734803ccbe9ecad3351df1d9768d8
+DIST nvidia-modprobe-515.43.04.tar.bz2 39098 BLAKE2B e4949e032da22e64e219d247b45c63d2d02c5f91bc2ebffe5d211d3cac30a7b638ff00a6dc0a60a097ef8a3eab8004f1146aabc4a355622baba5e288e0b02406 SHA512 6c0f7c342eff2c6012ec7f808e1524a516aa193c0ad35b4267358d31c38479a0b35abaf9824bb2ba2159e8dcd04f8d16e8483e48d54f0853d045291462d4f4f3
DIST nvidia-persistenced-390.147.tar.bz2 48712 BLAKE2B d8b2587c8b4374dcff198d8aae1468d30197d9b097badddbec34f0c41e3c4ab4f27b568f152a4c7a4416b3ee15194ae07442c45c50d086a6f4e7e69a5c54f42d SHA512 5877f7b0a40d54b1ca746b2fa1f1270d1ff605068dcf944e078d4cb547bc6f79c08ea9d4fbe3e94e8cd528b9721a89147d43ac849df71b2dc1d903fe1439c4a5
DIST nvidia-persistenced-470.103.01.tar.bz2 46549 BLAKE2B ad25193ba3abe1a5a30233aedb1596822a4af1aa74e6862c4449567408bd84ab40526301f600bfeae938c443f26dfdabd7f912888cfd2e307fc7867d7750180e SHA512 00ab77bb84b90bfeced488353db674334796b10bbd9c8da9ed682d668db800aa7bbcba20033d21bbee6663f0659dd17daf3298cb1384f41a89409a5f3a162de6
DIST nvidia-persistenced-510.68.02.tar.gz 54673 BLAKE2B 2a19eb1f410f75e726d36996e757f4f99c57633aec6758390319a084da9fc86a831cfe914286f16a20a0feaa9a29466877573f99c4b850ed0631b2335d2a3761 SHA512 ce990370e29bfe762a23a1dc6a0133a1ad4015405980d82f234e94a27cd4ea4c9fa46d52d5db4463dd617babda4069595c1963a0a10b0f019209095f5bb9015b
+DIST nvidia-persistenced-515.43.04.tar.bz2 47165 BLAKE2B 5cf6de13a6bd238d664b73d389ff0c1fb1e732996564449a4875821f10a777839fd42672e012b04cdb5916aace53b6712c8a4174575a412dd989d6772adc75a2 SHA512 b3e0d18d81f437e4fa7f464bd76fadc6af753acdd36ba9f20407dd9d35f7807d3ff64c74e5a5fb353779251e8c47205ff69097e7a432140aa91b26ab01aff9da
DIST nvidia-settings-390.147.tar.bz2 1109104 BLAKE2B b0a2e0c832901db65f41e54d66d61abd9afbc528d1e8095e314d7ce5c1bf73c7bc8cc1857d909d9eab2e3b9ee97831c15c52f2725a8c9f84e00416c4e3db23d1 SHA512 67c30df042b9a9b923f05a26bd2e0bd85487fab0fe2c730ac48025561d652ff0f7455a56cc7951ed8ba2a300e019fa0e52fcd912b644d0d88fd2ac0e63de2327
DIST nvidia-settings-470.103.01.tar.bz2 1062124 BLAKE2B a9b95174a2309668951bb090812c9d2098d7bdefa210b396523eb59887fb3ea62f517398ab63cc9cfb395f90e6535c308fd43fb0ac406afba17713e01e98b19d SHA512 62be59eae75965762b5caf6bfb71ca993ee23cc0d12d385a7e67e62c8f9180555078dfae736cc6d6bc0b52525780e32e0b76152c5e4a1be669c6dd181c0f2465
DIST nvidia-settings-510.68.02.tar.gz 1248292 BLAKE2B c46b045e31749b5641dfc732f94d36ae89c7e5b0826bba4c9372fdc52a4fac3731b7d7767b5bafb66e2a5129889587b1a2468255270ca3f0cb16c19ea79878a3 SHA512 a0f89220b8b45d05de28509b4d758db1b8318a8d222f6948d45a60ead7cc917274b9ffcda1a7a11cb7740215b439c248fa6096f3011e7a74bde91cd3f093aecd
+DIST nvidia-settings-515.43.04.tar.bz2 1079278 BLAKE2B f19272358c75c2f5538966f848e4a1b9a558deda63da65f43ee410e3fa43c5e5534a42893cbc6127242ec1af90a149ffc27455d24c62d34135f8b1c04517b89e SHA512 e7a3bfff40ddb340b571613d75b9eb5819ac4a8df605fe3a805e25c5ec138d44ad129f83cd7e69bc8e9a96c5147b6ebc804624383bf4d069067ca06b5a8ee838
DIST nvidia-xconfig-390.147.tar.bz2 107426 BLAKE2B c7004dab351581176a4e00fc099a12374cb29f3306769724c874a17600d6c11e79ac807fe218022d72ccf83ed33789d2378b0cdba35e5f94458e30631d725384 SHA512 a530c649ff7e75706ba37072ee58d64d4758348a45b953396a0e9d2608e1d7c3d299298cb50b1e8ee0bf2f6f8817bca64637b77e18aab0685a4edd630f18fb9a
DIST nvidia-xconfig-470.103.01.tar.bz2 108687 BLAKE2B 2e5de637f9ba7bb516fd1a6801f8ee5be2934f99503bd20a62eaf87c0105d7624ef8de993614b1316ea8d203f9b7a6be07d3c9d5005d8a6306b7fc89cc0bb443 SHA512 abbabb3bf650395237759cbfaa39565893156ae87d07855bc96bfa0f46e10f34fd9efb628ef184f4dd525f80c63c62938b9661c9a4f3f5e1e5420ae1fdf26f0e
DIST nvidia-xconfig-510.68.02.tar.gz 144010 BLAKE2B 11c8e91229839be57aee59b8bf5fd325636cf2c8de7cc1c42e79ee3e6abd884d4ec29d3acefc8bd294a8cce7b9a17c253323136b439ff410f38dbf9d90889018 SHA512 40bb5dff12477cc7e69ced0bd9ffb8fc1c6ac2f2591b652867165896d7749126afcd250c1f78056725243b5c3f0350748d4d68df0be639e7173a5abc1614b25e
+DIST nvidia-xconfig-515.43.04.tar.bz2 109791 BLAKE2B d85d5f59be3e9cd919f0c89f2553186499e632bb77a46286ac1b3ef6a8adf2cd2ac1bc09dfa3dd4dc2f4017f9d3dd8d3d3f76f617d3a52e4e777a85218bbd525 SHA512 0eac9cda62fe1a9c5a5be11bffd5e6b06796626ed57ed602285bfd33422cc5f978a33664f39db8a94e46741ce89fa18d2c183945f42cc6bd1e52b6e1c54d9cc1
diff --git a/x11-drivers/nvidia-drivers/metadata.xml b/x11-drivers/nvidia-drivers/metadata.xml
index 564715704a61..49c249600dde 100644
--- a/x11-drivers/nvidia-drivers/metadata.xml
+++ b/x11-drivers/nvidia-drivers/metadata.xml
@@ -11,6 +11,7 @@
</maintainer>
<use>
<flag name="driver">Install kernel driver modules</flag>
+ <flag name="kernel-open">Use open source variant of drivers (Turing/Ampere+ GPUs only, very experimental)</flag>
<flag name="persistenced">Install the persistence daemon for keeping devices state when unused</flag>
<flag name="static-libs">Install the XNVCtrl static library for accessing sensors and other features</flag>
<flag name="tools">Install additional tools such as nvidia-settings</flag>
@@ -22,5 +23,6 @@
<remote-id type="github">NVIDIA/nvidia-persistenced</remote-id>
<remote-id type="github">NVIDIA/nvidia-settings</remote-id>
<remote-id type="github">NVIDIA/nvidia-xconfig</remote-id>
+ <remote-id type="github">NVIDIA/open-gpu-kernel-modules</remote-id>
</upstream>
</pkgmetadata>
diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-515.43.04.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-515.43.04.ebuild
new file mode 100644
index 000000000000..6aa9c68dc6c0
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-515.43.04.ebuild
@@ -0,0 +1,474 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+MODULES_OPTIONAL_USE="driver"
+inherit desktop flag-o-matic linux-mod multilib readme.gentoo-r1 \
+ systemd toolchain-funcs unpacker user-info
+
+NV_KERNEL_MAX="5.17"
+NV_URI="https://download.nvidia.com/XFree86/"
+
+DESCRIPTION="NVIDIA Accelerated Graphics Driver"
+HOMEPAGE="https://www.nvidia.com/download/index.aspx"
+SRC_URI="
+ amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run )
+ arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run )
+ $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \
+ nvidia-{installer,modprobe,persistenced,settings,xconfig}{,})"
+# nvidia-installer is unused but here for GPL-2's "distribute sources"
+S="${WORKDIR}"
+
+LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl"
+SLOT="0/${PV%%.*}"
+#KEYWORDS="-* ~amd64 ~arm64" # beta version, keeping unkeyworded
+IUSE="+X abi_x86_32 abi_x86_64 +driver kernel-open persistenced +static-libs +tools wayland"
+REQUIRED_USE="kernel-open? ( driver )"
+
+COMMON_DEPEND="
+ acct-group/video
+ sys-libs/glibc
+ X? ( x11-libs/libpciaccess )
+ persistenced? (
+ acct-user/nvpd
+ net-libs/libtirpc:=
+ )
+ tools? (
+ dev-libs/atk
+ dev-libs/glib:2
+ dev-libs/jansson:=
+ media-libs/harfbuzz:=
+ x11-libs/cairo
+ x11-libs/gdk-pixbuf:2
+ x11-libs/gtk+:3
+ x11-libs/libX11
+ x11-libs/libXext
+ x11-libs/libXxf86vm
+ x11-libs/pango
+ )"
+RDEPEND="
+ ${COMMON_DEPEND}
+ X? (
+ media-libs/libglvnd[X,abi_x86_32(-)?]
+ x11-libs/libX11[abi_x86_32(-)?]
+ x11-libs/libXext[abi_x86_32(-)?]
+ )
+ wayland? (
+ gui-libs/egl-gbm
+ >=gui-libs/egl-wayland-1.1.7-r1
+ media-libs/libglvnd
+ )"
+DEPEND="
+ ${COMMON_DEPEND}
+ static-libs? (
+ x11-libs/libX11
+ x11-libs/libXext
+ )
+ tools? (
+ media-libs/libglvnd
+ sys-apps/dbus
+ x11-base/xorg-proto
+ x11-libs/libXrandr
+ x11-libs/libXv
+ x11-libs/libvdpau
+ )"
+BDEPEND="
+ sys-devel/m4
+ virtual/pkgconfig"
+
+QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*"
+
+PATCHES=(
+ "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch
+ "${FILESDIR}"/nvidia-settings-390.144-desktop.patch
+ "${FILESDIR}"/nvidia-settings-390.144-no-gtk2.patch
+ "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch
+)
+
+pkg_setup() {
+ use driver || return
+
+ local CONFIG_CHECK="
+ BACKLIGHT_CLASS_DEVICE
+ PROC_FS
+ ~DRM_KMS_HELPER
+ ~SYSVIPC
+ ~!LOCKDEP
+ ~!SLUB_DEBUG_ON
+ !DEBUG_MUTEXES"
+ local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection
+ of drivers (no custom config), and for wayland / nvidia-drm.modeset=1.
+ Cannot be directly selected in the kernel's menuconfig, and may need
+ selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
+ DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
+
+ use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
+
+ MODULE_NAMES="
+ nvidia(video:kernel)
+ nvidia-drm(video:kernel)
+ nvidia-modeset(video:kernel)
+ nvidia-peermem(video:kernel)
+ nvidia-uvm(video:kernel)"
+ use kernel-open && MODULE_NAMES=${MODULE_NAMES//:kernel/:kernel-open}
+
+ linux-mod_pkg_setup
+
+ [[ ${MERGE_TYPE} == binary ]] && return
+
+ BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" SYSOUT="${KV_OUT_DIR}"'
+ BUILD_TARGETS="modules"
+
+ if linux_chkconfig_present CC_IS_CLANG; then
+ ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
+
+ BUILD_PARAMS+=' CC=${CHOST}-clang'
+ if linux_chkconfig_present LD_IS_LLD; then
+ BUILD_PARAMS+=' LD=ld.lld'
+ if linux_chkconfig_present LTO_CLANG_THIN; then
+ # kernel enables cache by default leading to sandbox violations
+ BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
+ fi
+ fi
+ fi
+
+ if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
+ ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"
+ ewarn "or was not tested with it. It is recommended to use one of:"
+ ewarn " <=sys-kernel/gentoo-kernel-${NV_KERNEL_MAX}.x"
+ ewarn " <=sys-kernel/gentoo-sources-${NV_KERNEL_MAX}.x"
+ ewarn "You are free to try or use /etc/portage/patches, but support will"
+ ewarn "not be given and issues wait until NVIDIA releases a fixed version"
+ ewarn "(Gentoo will not accept patches for this)."
+ ewarn
+ ewarn "Do _not_ file a bug report if run into issues."
+ ewarn
+ fi
+}
+
+src_prepare() {
+ # make patches usable across versions
+ rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die
+ rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die
+ rm nvidia-settings && mv nvidia-settings{-${PV},} || die
+ rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die
+
+ default
+
+ # prevent detection of incomplete kernel DRM support (bug #603818)
+ sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \
+ -i kernel{,-open}/conftest.sh || die
+
+ # adjust service files
+ sed 's/__USER__/nvpd/' \
+ nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
+ > "${T}"/nvidia-persistenced.service || die
+ use !amd64 || sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die
+
+ # enable nvidia-drm.modeset=1 by default with USE=wayland
+ cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die
+ use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die
+
+ # makefile attempts to install wayland library even if not built
+ use wayland || sed -i 's/ WAYLAND_LIB_install$//' \
+ nvidia-settings/src/Makefile || die
+}
+
+src_compile() {
+ tc-export AR CC LD OBJCOPY
+
+ NV_ARGS=(
+ PREFIX="${EPREFIX}"/usr
+ HOST_CC="$(tc-getBUILD_CC)"
+ HOST_LD="$(tc-getBUILD_LD)"
+ NV_USE_BUNDLED_LIBJANSSON=0
+ NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out
+ WAYLAND_AVAILABLE=$(usex wayland 1 0)
+ XNVCTRL_CFLAGS=-fPIC #840389
+ )
+
+ use driver && linux-mod_src_compile
+
+ emake "${NV_ARGS[@]}" -C nvidia-modprobe
+ use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced
+ use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig
+
+ if use tools; then
+ # cflags: avoid noisy logs, only use here and set first to let override
+ # ldflags: abi currently needed if LD=ld.lld
+ CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \
+ RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" \
+ emake "${NV_ARGS[@]}" -C nvidia-settings
+ elif use static-libs; then
+ emake "${NV_ARGS[@]}" -C nvidia-settings/src out/libXNVCtrl.a
+ fi
+}
+
+src_install() {
+ local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir)
+
+ NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} )
+
+ local -A paths=(
+ [APPLICATION_PROFILE]=/usr/share/nvidia
+ [CUDA_ICD]=/etc/OpenCL/vendors
+ [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d
+ [FIRMWARE]=/lib/firmware/nvidia/${PV}
+ [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm
+ [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d
+ [VULKAN_ICD_JSON]=/usr/share/vulkan
+ [WINE_LIB]=/usr/${libdir}/nvidia/wine
+ [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d
+
+ [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions
+ [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules
+ [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules
+ )
+
+ local skip_files=(
+ # nvidia_icd/layers(vulkan): skip with -X too as it uses libGLX_nvidia
+ $(usev !X "
+ libGLX_nvidia libglxserver_nvidia
+ nvidia_icd.json nvidia_layers.json")
+ $(usev !wayland libnvidia-vulkan-producer)
+ libGLX_indirect # non-glvnd unused fallback
+ libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source
+ libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm
+ libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland
+ )
+ local skip_modules=(
+ $(usev !X "nvfbc vdpau xdriver")
+ $(usev !driver gsp)
+ installer nvpd # handled separately / built from source
+ )
+ local skip_types=(
+ GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd
+ OPENCL_WRAPPER.\* # virtual/opencl
+ DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused
+ )
+
+ local DOCS=(
+ README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json
+ nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt
+ )
+ local HTML_DOCS=( html/. )
+ einstalldocs
+
+ local DISABLE_AUTOFORMATTING=yes
+ local DOC_CONTENTS="\
+Trusted users should be in the 'video' group to use NVIDIA devices.
+You can add yourself by using: gpasswd -a my-user video\
+$(usev driver "
+
+Like all out-of-tree kernel modules, it is necessary to rebuild
+${PN} after upgrading or rebuilding the Linux kernel
+by for example running \`emerge @module-rebuild\`. Alternatively,
+if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}),
+this can be automated by setting USE=dist-kernel globally.
+
+Loaded kernel modules also must not mismatch with the installed
+${PN} version (excluding -r revision), meaning should
+ensure \`eselect kernel list\` points to the kernel that will be
+booted before building and preferably reboot after upgrading
+${PN} (the ebuild will emit a warning if mismatching).
+
+See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\
+$(use amd64 && usev !abi_x86_32 "
+
+Note that without USE=abi_x86_32 on ${PN}, 32bit applications
+(typically using wine / steam) will not be able to use GPU acceleration.")
+
+For general information on using ${PN}, please see:
+https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers"
+ readme.gentoo_create_doc
+
+ if use driver; then
+ linux-mod_src_install
+
+ insinto /etc/modprobe.d
+ doins "${T}"/nvidia.conf
+
+ # used for gpu verification with binpkgs (not kept, see pkg_preinst)
+ insinto /usr/share/nvidia
+ doins supported-gpus/supported-gpus.json
+ fi
+
+ emake "${NV_ARGS[@]}" -C nvidia-modprobe install
+ fowners :video /usr/bin/nvidia-modprobe #505092
+ fperms 4710 /usr/bin/nvidia-modprobe
+
+ if use persistenced; then
+ emake "${NV_ARGS[@]}" -C nvidia-persistenced install
+ newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced
+ newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced
+ systemd_dounit "${T}"/nvidia-persistenced.service
+ fi
+
+ if use tools; then
+ emake "${NV_ARGS[@]}" -C nvidia-settings install
+
+ doicon nvidia-settings/doc/nvidia-settings.png
+ domenu nvidia-settings/doc/nvidia-settings.desktop
+
+ exeinto /etc/X11/xinit/xinitrc.d
+ newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
+ fi
+
+ if use static-libs; then
+ dolib.a nvidia-settings/src/out/libXNVCtrl.a
+
+ insinto /usr/include/NVCtrl
+ doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h
+ fi
+
+ use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install
+
+ # mimic nvidia-installer by reading .manifest to install files
+ # 0:file 1:perms 2:type 3+:subtype/arguments -:module
+ local m into
+ while IFS=' ' read -ra m; do
+ ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] ||
+ eval '[[ " ${m[0]##*/}" =~ ^(\ '${skip_files[*]/%/.*|\\}' )$ ]]' ||
+ eval '[[ " ${m[2]}" =~ ^(\ '${skip_types[*]/%/|\\}' )$ ]]' ||
+ has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue
+
+ case ${m[2]} in
+ MANPAGE)
+ gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert
+ continue
+ ;;
+ GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../
+ VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/
+ esac
+
+ if [[ -v paths[${m[2]}] ]]; then
+ into=${paths[${m[2]}]}
+ elif [[ ${m[2]} =~ _BINARY$ ]]; then
+ into=/opt/bin
+ elif [[ ${m[3]} == COMPAT32 ]]; then
+ use abi_x86_32 || continue
+ into=/usr/${libdir32}
+ elif [[ ${m[2]} =~ _LIB$|_SYMLINK$ ]]; then
+ into=/usr/${libdir}
+ else
+ die "No known installation path for ${m[0]}"
+ fi
+ [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/}
+ [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/}
+
+ if [[ ${m[2]} =~ _SYMLINK$ ]]; then
+ [[ ${m[4]: -1} == / ]] && m[4]=${m[5]}
+ dosym ${m[4]} ${into}/${m[0]}
+ continue
+ fi
+ [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] &&
+ dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest
+
+ printf -v m[1] %o $((m[1] | 0200)) # 444->644
+ insopts -m${m[1]}
+ insinto ${into}
+ doins ${m[0]}
+ done < .manifest || die
+
+ # MODULE:installer non-skipped extras
+ exeinto /lib/systemd/system-sleep
+ doexe systemd/system-sleep/nvidia
+ dobin systemd/nvidia-sleep.sh
+ systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service
+
+ dobin nvidia-bug-report.sh
+
+ # MODULE:powerd extras
+ if use amd64; then
+ systemd_dounit systemd/system/nvidia-powerd.service
+
+ insinto /usr/share/dbus-1/system.d
+ doins nvidia-dbus.conf
+ fi
+}
+
+pkg_preinst() {
+ has_version "${CATEGORY}/${PN}[abi_x86_32]" && NV_HAD_ABI32=
+ has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND=
+
+ use driver || return
+ linux-mod_pkg_preinst
+
+ # set video group id based on live system (bug #491414)
+ local g=$(egetent group video | cut -d: -f3)
+ [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')"
+ sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die
+
+ # try to find driver mismatches using temporary supported-gpus.json
+ for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do
+ g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \
+ "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null)
+ if [[ ${g} ]]; then
+ g=$((${g##*\"}+1))
+ if ver_test -ge ${g}; then
+ NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}"
+ break
+ fi
+ fi
+ done
+ rm "${ED}"/usr/share/nvidia/supported-gpus.json || die
+}
+
+pkg_postinst() {
+ use driver && linux-mod_pkg_postinst
+
+ readme.gentoo_print_elog
+
+ if [[ -r /proc/driver/nvidia/version &&
+ $(</proc/driver/nvidia/version) != *" ${PV} "* ]]; then
+ ewarn "Currently loaded NVIDIA modules do not match the newly installed"
+ ewarn "libraries and may prevent launching GPU-accelerated applications."
+ use driver && ewarn "The easiest way to fix this is usually to reboot."
+ fi
+
+ if [[ $(</proc/cmdline) == *slub_debug=[!-]* ]]; then
+ ewarn "Detected that the current kernel command line is using 'slub_debug=',"
+ ewarn "this may lead to system instability/freezes with this version of"
+ ewarn "${PN}. Bug: https://bugs.gentoo.org/796329"
+ fi
+
+ if [[ -v NV_LEGACY_MASK ]]; then
+ ewarn
+ ewarn "***WARNING***"
+ ewarn
+ ewarn "You are installing a version of ${PN} known not to work"
+ ewarn "with a GPU of the current system. If unwanted, add the mask:"
+ if [[ -d ${EROOT}/etc/portage/package.mask ]]; then
+ ewarn " echo '${NV_LEGACY_MASK}' > ${EROOT}/etc/portage/package.mask/${PN}"
+ else
+ ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask"
+ fi
+ ewarn "...then downgrade to a legacy branch if possible. For details, see:"
+ ewarn "https://www.nvidia.com/object/IO_32667.html"
+ fi
+
+ if use kernel-open; then
+ ewarn
+ ewarn "Open source variant of ${PN} was selected, be warned it is experimental"
+ ewarn "and only usable with Turing / Ampere and later GPUs. Please also see:"
+ ewarn "${EROOT}/usr/share/doc/${PF}/html/kernel_open.html"
+ fi
+
+ if use !abi_x86_32 && [[ -v NV_HAD_ABI32 ]]; then
+ elog
+ elog "USE=abi_x86_32 is disabled, 32bit applications will not be able to"
+ elog "use nvidia-drivers for acceleration without it (e.g. commonly used"
+ elog "with app-emulation/wine-* or steam). Re-enable if needed."
+ fi
+
+ if use wayland && use driver && [[ ! -v NV_HAD_WAYLAND ]]; then
+ elog
+ elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1"
+ elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered"
+ elog "experimental but is required for wayland."
+ elog
+ elog "If you experience issues, either disable wayland or edit nvidia.conf."
+ elog "Of note, may possibly cause issues with SLI and Reverse PRIME."
+ fi
+}