summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIonen Wolkens <sudinave@gmail.com>2021-03-21 16:52:10 +0100
committerDavid Seifert <soap@gentoo.org>2021-03-21 16:52:10 +0100
commit26146d1510fd678538b7d02400c1eb8e66e20212 (patch)
treeecb081a9d8bc49a75975592648bf8e9ad948c5ea /x11-drivers
parentx11-misc/primus: remove old 0.2 (diff)
downloadgentoo-26146d1510fd678538b7d02400c1eb8e66e20212.tar.gz
gentoo-26146d1510fd678538b7d02400c1eb8e66e20212.tar.bz2
gentoo-26146d1510fd678538b7d02400c1eb8e66e20212.zip
x11-drivers/nvidia-drivers: bump to 460.67 with refactored ebuild
ebuild carries a lot of history and, rather than cleanups, it needed something closer to a rewrite. Bugfixes: - Removed all udev rules to solve long standing issues (bug #454740) - Install libraries with no X11 dependencies with USE=-X, notably for headless OpenCL/CUDA (bug #561706) - Install systemd unit for persistenced + nvpd user (bug #591638) - Add custom error message for DRM_KMS_HELPER and ensure driver doesn't attempt building DRM support without it (bug #603818) - Warn about AMD SME if enabled by default (bug #652408) - Distribute extra sources to lift RESTRICT="bindist mirror", the nvidia-driver.eclass is no longer used (bug #732702) - Build modprobe and persistenced from source (bug #747145) - Use system locations for vulkan icd/layers (bug #749600) Others: - Dropped IUSE=compat/multilib/kms/uvm/wayland > compat: was for non-GLVND variants and currently a no-op > multilib: obsolete, abi_x86_32 does all that's needed > kms/uvm: modules are loaded by nvidia-modprobe as-needed and there's not much sense in skipping installation. Will also save OpenCL/CUDA packages from having to depend on [uvm] > wayland: library is provided by gui-libs/egl-wayland instead which now also provides pkgconfig files and can be a newer version. optfeature warning was added for awareness. - Dropped REQUIRED_USE, all USE can now be used independently, e.g. now possible to get libXNVCtrl.a (static-libs) without the deps-heavy USE=tools - Dropped locale patch, the offending code it was meant to fix is gone. - Dropped linker patch, uses right linker even with -native-symlinks. - Added modprobe.d .conf to blacklist nouveau by default. - Patched nvidia-modprobe to respect nvidia.conf's permissions when creating uvm devices, was previously created as world read-write. - No longer installing libOpenCL.so loader (not needed to use OpenCL, was used by the no longer available eselect-opencl). - nvidia-persistenced init script simplified and updated for nvpd user. - nvidia-smi init script removed (all it did was query cards every 300 seconds), mentioned behavior is no longer observable (fan scales normally without X) and it wasn't intended for this purpose. - Removed I2C_NVIDIA_GPU check as it caused unnecessary noise for gentoo-kernel-bin users (built as module), and being a bad thing even if loaded is questionable. - Attempt to reduce message noise. The only fatal CONFIG_CHECK is fairly rare so there's little reason to check twice with pkg_pretend. - ... but added new conditional messages to explain important things often seen as common sense but that a new user likely won't know. - Replaced the nvidia-driver.eclass legacy test with a compact version that reads supported-gpus.json (usable on >450). - More strict deps, some may sound strange but nvidia-settings only use headers for some of these (dbus/Xrandr/Xv/vdpau). > X? libs kept separate as it's the only one needing multilib deps. > pax-utils now unconditional for scanelf as libraries are always installed. Alternatively could've generated those, but prefer to leave it easier to maintain for future generations. > virtual/opencl removed, no sense in the drivers depending on this and it's instead applications using opencl that should. > Added MODULES_OPTIONAL_USE="driver" to handle linux-mod deps - Added MIT license for persistenced - Added ZLIB license for supported-gpus.json - NV_KERNEL_MAX (previously NV_KV_MAX_PLUS) set to be <=5.11 form rather than <5.12 given that often confused users thinking it meant 5.12 support from quick looks. - arm64 support "should" work but runtime untested - And a long list of cleanups that "hopefully" won't cause new issues. Closes: https://bugs.gentoo.org/454740 Closes: https://bugs.gentoo.org/561706 Closes: https://bugs.gentoo.org/591638 Closes: https://bugs.gentoo.org/603818 Closes: https://bugs.gentoo.org/652408 Closes: https://bugs.gentoo.org/732702 Closes: https://bugs.gentoo.org/747145 Closes: https://bugs.gentoo.org/749600 Signed-off-by: Ionen Wolkens <sudinave@gmail.com> Signed-off-by: David Seifert <soap@gentoo.org>
Diffstat (limited to 'x11-drivers')
-rw-r--r--x11-drivers/nvidia-drivers/Manifest7
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-blacklist-nouveau.conf3
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch12
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd7
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd12
-rw-r--r--x11-drivers/nvidia-drivers/nvidia-drivers-460.67.ebuild391
6 files changed, 432 insertions, 0 deletions
diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest
index fd3ddf917389..a85b7fa514e7 100644
--- a/x11-drivers/nvidia-drivers/Manifest
+++ b/x11-drivers/nvidia-drivers/Manifest
@@ -1,9 +1,16 @@
+DIST NVIDIA-Linux-aarch64-460.67.run 112551235 BLAKE2B cc1166454f6e8771c7fe97010906919e9f2afd74ac86321006628f90f4d8dee033c3e09b2d9cac9063fe3fd313c0b529b347bcf38c051588ca7a972617c45026 SHA512 6ba17844dd215967f2f55a6620535464f244075a13f4b2b6d0ffaeeb6d97397fae0ba0de032d971847556d7b78ac8a1010ecec5127f45eb7ec73db87b1507ca1
DIST NVIDIA-Linux-x86-390.141.run 49589744 BLAKE2B 304672806b89885adbf8459ea99ca872769e44a42ff041a5b79ef05d113d7717f505f543441e7a2fc6c569f6d66391f0380a4f23f3e68108c8de817bf251f850 SHA512 6dfde3b54520070954b45f6bc071251084e1741f55e582b1abd806eb367e4b9ce0015615bf6a887fa784d075b3db08b6940da4163b960969773d1bdc52b4961e
DIST NVIDIA-Linux-x86_64-390.141.run 85330901 BLAKE2B 7759d8cf6c9a75607b9a3ecd53cdd6f6a93f2f372d740a5a87d4d3f41a22f3bd953cc7dd6a0dc0e23a829ec86df8d65b9de499a76cfd4266a13b0aa3288aceb5 SHA512 5448d70e6e64a6403e61a004d83c69a442dd8ed0d61da3a31d3e3b7943c06c559a66b0f8d135982868ecbf209a965f60dae1a633367630b4d9287f725bbaa53c
DIST NVIDIA-Linux-x86_64-450.102.04.run 141391114 BLAKE2B 019f928464b23d2a86bfdd255b7651e3cfe2b0b6ebf58d1b4a6ba1f27990e1d050d1e2429ba4aa60b966b04e775939084a04d82d1dd3482a10b39375b17b1c31 SHA512 1d13de540da36274a360ea6bcd1ce01eaae103fe417b42aa8f9ac757c382b06da455a78cf6798310179f90e2afeadf3a8c9f3398186490c3c0f9079021e850ed
DIST NVIDIA-Linux-x86_64-460.39.run 178310565 BLAKE2B 65931f34ff47de02933797f60128c66c8774f3b217b79e82f781cd50560835ec79c37b7e63fb50231a22646f0cd7cf968d1fbe1ec6c2b3732a1c565b68de7bcb SHA512 9275a58ff0e72c3ee033bd18fa9e9dbb0203d2961a63e7cc04444889118eb4029c60bb10c2af8f230c1aa4aa30769131ea8c01f3bc4e7453336ad9c03ba23b42
DIST NVIDIA-Linux-x86_64-460.56.run 178496173 BLAKE2B 8f84a403ccaa9a92186cac9fb2dee9600cd29915cdacf475b6a1105772ffd52c671ef217a1201fbcd9192e858ec17796fd77b817887c79c43c266d32671fe7d0 SHA512 a61855576a27cdd2e48906ecb49cd1e9f88d14a8358aa4bdc57d59e2dfa64b394b2dcee45184d75e889fac6ebedcaaff902a07428c7f9eb011cf265228c6eb4e
+DIST NVIDIA-Linux-x86_64-460.67.run 177691692 BLAKE2B 25a7d87cc128933a98100d7c5ef37f93c3a870c096eea3228a28ef79d712ce104608f9422221cc1eadc21dccbbc8bc41ab1832795cfee75e217600ed0d76489e SHA512 80fdc023a8ce80e3a103896f28a5564bb43903af6bfc719f755c48eb225e79ec6abf219ab20eb80ada5808ef932ef5fa0fe710c6e0a07dd8a248daff2ba3b898
+DIST nvidia-installer-460.67.tar.gz 198484 BLAKE2B 0eaf3e3eccd6749e4fe89394905dded58e739f42cbc33c8a91575f4505030a216670fc8c0fd4d1d42659acf301c9ba59d4052a80c6eba6c5db84ed022acb2620 SHA512 8fff0fa13a82cb7eaf2fd1d05be509e9124e67bb05810f8937fb1f16c4a2362a5c1a50bc9a5155cfc90a9bbcee38a54fb5ae0ae164e205900a49f6d21779d54f
+DIST nvidia-modprobe-460.67.tar.gz 43140 BLAKE2B 8243d355f9d51495c9d09f25ccbcb39c0a6ef472cbfaded98f10818fae655e1cf62ff2edcf40baea72b8cca9eebc947742b2516bb057410239193201bb843538 SHA512 16c8239b54988622196e0eea113173e44ff8b60cdcdf585bf859e6440aff2c6699bb107962776e69056dd7d5e3bbd6289ea628a2255ac27e22ef79521e9baad3
+DIST nvidia-persistenced-460.67.tar.gz 53334 BLAKE2B 1354ec98fd2b95d264fd7df6219f639cf5d73173e6f0843a0880e6b18953904412cb756bd2c60432f6ae4c253d047515a9e32a128210fd94386ae6bc9a341b5c SHA512 0b4f7d8aa781c3536f6cd020225d2a3bab4b83498090419198488a2bec811534e61ba90461ae846bd09f4530f19984d77ca41edf0a851b1b700d1c0e053d537f
DIST nvidia-settings-390.141.tar.bz2 1108755 BLAKE2B 210c33d4bb483dd9abe13275feb641a00d7c39a7222cbe828c925b9cfca6d4422f8fa3333dd77b73f2ba4071a7badf77625be88e02a1835177bda490c3c3c368 SHA512 44bf5f6b5bfbe3146f97d9ac82a75cc5653b6002002623ac6fa6cd233bbd3ef0d15f0b8091b59de5dbfdbde4fbe1b5212c9f9a1653ec98597c9049c9b137902e
DIST nvidia-settings-450.102.04.tar.bz2 1057126 BLAKE2B 4e27ac75441d455122860b3834f2584e4736fff1f641e9a1d3ced4a354cb0e0e35c4e7a71e7bc05940d585e0ceca576f726fdfffbb84aae8057d06355b91293f SHA512 33f27b9a2832f7f24603d3a741b6c34cdd3f27a7075b523f8b98ae89325f810e13c134fcc7503e72d44a6f6c7a0d8587bfdad898a4ab5fa252bd9c7360a32341
DIST nvidia-settings-460.39.tar.bz2 1060391 BLAKE2B badfe9e5fa3ca7f5389369b01f839aa37b687e99bac47663b320602ada4d4e8dfb7c6fa4f64cee358a25ced7d9393ddfa4242147d9b645ae4fbd1b68310f3363 SHA512 a5f01d2a627695932399804776923a90050ec66b19c9d95ed34d11fc79e41604fe25474ed7b7bfec68b2115dd6fccb444b66427ce78c1d67b1b01f072bc8892a
DIST nvidia-settings-460.56.tar.bz2 1060604 BLAKE2B cd1480e42ab2b25b399f19b458a1d5252d1b77d263ddecbad2d61f0445ba9f0ddf81fc944ac1136c273dfd1d21d06385bcfac9bdd7a7dc02f75302a6b8276df4 SHA512 018eb3cb7f25b926aa620201979b0efaaa82e7f036c4870a1e1234f5aac3ab9cfd48846d7eedd7ed38c3035eface3f2afe1a0d5de7a67e53e6bea760aa99fa72
+DIST nvidia-settings-460.67.tar.gz 1233189 BLAKE2B 33ffceefea4e184cb1873cdce97db26637e87cd20c82bcabcbfe88bcb084ac3d833ac5688cafa33a5a89383040d5c1c5d46de9c3f9a8ba6174574aa57aea2e46 SHA512 d1828379aa477394747ae3e5d3505e864d38a349dd159a04cb263613380afea9aea2081300b0d2b8ae205b800bfe6e8ba504e612989da394d757f00e4399b617
+DIST nvidia-xconfig-460.67.tar.gz 142323 BLAKE2B 09c7281de09a2c2968b5f4a48eca63110e6db988429c844b55f8efc28fbcd9d44c79ad47149c25f657c2a98ae7576c01b2c9b7f643b8321fe1393adc571ebcaa SHA512 0e65c81ec40d3eaeec036fbd8f46a3052a75ff0ad200c58438ff6c782a5764e62e51d03b4a2080770c32522894641288ac495f62bc39c3d5658b1ff87c9f6cdd
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-blacklist-nouveau.conf b/x11-drivers/nvidia-drivers/files/nvidia-blacklist-nouveau.conf
new file mode 100644
index 000000000000..b15fe0a3d92b
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/files/nvidia-blacklist-nouveau.conf
@@ -0,0 +1,3 @@
+# NVIDIA's official drivers and nouveau cannot be used at same time.
+# Comment out the following line if you wish to allow nouveau.
+blacklist nouveau
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch b/x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch
new file mode 100644
index 000000000000..6ffd42ff77ea
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/files/nvidia-modprobe-390.141-uvm-perms.patch
@@ -0,0 +1,12 @@
+Create /dev/nvidia-uvm* by respecting nvidia.conf's permissions.
+--- a/nvidia-modprobe/modprobe-utils/nvidia-modprobe-utils.c
++++ b/nvidia-modprobe/modprobe-utils/nvidia-modprobe-utils.c
+@@ -742,6 +742,6 @@
+ }
+
+- return mknod_helper(major, base_minor, NV_UVM_DEVICE_NAME, NULL) &&
+- mknod_helper(major, base_minor + 1, NV_UVM_TOOLS_DEVICE_NAME, NULL);
++ return mknod_helper(major, base_minor, NV_UVM_DEVICE_NAME, NV_PROC_REGISTRY_PATH) &&
++ mknod_helper(major, base_minor + 1, NV_UVM_TOOLS_DEVICE_NAME, NV_PROC_REGISTRY_PATH);
+ }
+
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd
new file mode 100644
index 000000000000..e06d53c0c98d
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.confd
@@ -0,0 +1,7 @@
+# configuration file for /etc/init.d/nvidia-persistenced
+
+# NVPD_USER: user to run as, needs access to /dev/nvidia* (video group)
+NVPD_USER="nvpd"
+
+# ARGS: additional arguments, see nvidia-persistenced(1)
+ARGS=""
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd
new file mode 100644
index 000000000000..e199efc1e54e
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.initd
@@ -0,0 +1,12 @@
+#!/sbin/openrc-run
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+description="Maintain persistent software state in the NVIDIA driver"
+command="nvidia-persistenced"
+command_args="${NVPD_USER:+--user ${NVPD_USER}} ${ARGS}"
+pidfile="/var/run/nvidia-persistenced/nvidia-persistenced.pid"
+
+stop_post() {
+ rmdir "${pidfile%/*}" 2>/dev/null || true
+}
diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-460.67.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-460.67.ebuild
new file mode 100644
index 000000000000..40107b838e5b
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-460.67.ebuild
@@ -0,0 +1,391 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+MODULES_OPTIONAL_USE="driver"
+inherit desktop linux-info linux-mod multilib-build \
+ optfeature systemd toolchain-funcs unpacker
+
+NV_KERNEL_MAX="5.11"
+NV_BIN_URI="https://download.nvidia.com/XFree86/Linux-"
+NV_GIT_URI="https://github.com/NVIDIA/nvidia-"
+
+DESCRIPTION="NVIDIA Accelerated Graphics Driver"
+HOMEPAGE="https://www.nvidia.com/download/index.aspx"
+SRC_URI="
+ amd64? ( ${NV_BIN_URI}x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run )
+ arm64? ( ${NV_BIN_URI}aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run )
+ ${NV_GIT_URI}installer/archive/${PV}.tar.gz -> nvidia-installer-${PV}.tar.gz
+ ${NV_GIT_URI}modprobe/archive/${PV}.tar.gz -> nvidia-modprobe-${PV}.tar.gz
+ ${NV_GIT_URI}persistenced/archive/${PV}.tar.gz -> nvidia-persistenced-${PV}.tar.gz
+ ${NV_GIT_URI}settings/archive/${PV}.tar.gz -> nvidia-settings-${PV}.tar.gz
+ ${NV_GIT_URI}xconfig/archive/${PV}.tar.gz -> nvidia-xconfig-${PV}.tar.gz"
+# nvidia-installer is unused but here for GPL-2's "distribute sources"
+S="${WORKDIR}"
+
+LICENSE="GPL-2 MIT NVIDIA-r2 ZLIB"
+SLOT="0/${PV%%.*}"
+KEYWORDS="-* ~amd64"
+IUSE="+X +driver static-libs +tools"
+
+COMMON_DEPEND="
+ acct-group/video
+ acct-user/nvpd
+ net-libs/libtirpc
+ tools? (
+ dev-libs/atk
+ dev-libs/glib:2
+ dev-libs/jansson
+ 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,${MULTILIB_USEDEP}]
+ x11-libs/libX11[${MULTILIB_USEDEP}]
+ x11-libs/libXext[${MULTILIB_USEDEP}]
+ )"
+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="
+ app-misc/pax-utils
+ virtual/pkgconfig"
+
+QA_PREBUILT="opt/* usr/lib*"
+
+CONFIG_CHECK="
+ ~DRM_KMS_HELPER
+ ~SYSVIPC
+ ~!AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
+ ~!LOCKDEP
+ !DEBUG_MUTEXES"
+ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection
+ of drivers (no custom config), and optional nvidia-drm.modeset=1.
+ Cannot be directly selected in the kernel's menuconfig, so enable
+ options such as CONFIG_DRM_FBDEV_EMULATION instead."
+
+PATCHES=(
+ "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch
+)
+DOCS=(
+ README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json
+ nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt
+)
+HTML_DOCS=( html/. )
+
+pkg_setup() {
+ use driver || return
+ BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KERNEL_DIR}"'
+ BUILD_TARGETS="modules" # defaults' clean sometimes deletes modules
+ MODULE_NAMES="
+ nvidia(video:kernel)
+ nvidia-drm(video:kernel)
+ nvidia-modeset(video:kernel)
+ nvidia-uvm(video:kernel)"
+ linux-mod_pkg_setup
+
+ if [[ ${MERGE_TYPE} != binary ]] && kernel_is gt ${NV_KERNEL_MAX/./ }; then
+ ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of nvidia-drivers"
+ ewarn "or was not tested with it. It is recommended to use one of:"
+ ewarn " <=sys-kernel/gentoo-kernel-${NV_KERNEL_MAX}"
+ ewarn " <=sys-kernel/gentoo-sources-${NV_KERNEL_MAX}"
+ 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
+ ewarn "Do _not_ file a bug report if run into issues."
+ ewarn
+ fi
+}
+
+src_prepare() {
+ # make user 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)/' \
+ -i kernel/conftest.sh || die
+
+ sed -e '/Exec=\|Icon=/s/_.*/nvidia-settings/' \
+ -e '/Categories=/s/_.*/System;Settings;/' \
+ -i nvidia-settings/doc/nvidia-settings.desktop || die
+
+ # remove gtk2 support (bug #592730)
+ sed '/^GTK2LIB = /d;/INSTALL.*GTK2LIB/,+1d' \
+ -i nvidia-settings/src/Makefile || die
+
+ sed 's/__USER__/nvpd/' \
+ nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
+ > nvidia-persistenced.service || die
+
+ gzip -d nvidia-{cuda-mps-control,smi}.1.gz || die
+}
+
+nvidia-drivers_make() {
+ emake -C nvidia-${1} ${2} \
+ DESTDIR="${ED}" PREFIX=/usr LIBDIR="${ED}/usr/$(get_libdir)" \
+ HOST_CC="$(tc-getBUILD_CC)" HOST_LD="$(tc-getBUILD_LD)" \
+ DO_STRIP= MANPAGE_GZIP= \
+ NV_USE_BUNDLED_LIBJANSSON=0 NV_VERBOSE=1 OUTPUTDIR=out
+}
+
+src_compile() {
+ tc-export AR CC LD OBJCOPY
+ # may no longer be relevant but kept as a safety
+ export DISTCC_DISABLE=1 CCACHE_DISABLE=1
+
+ use driver && linux-mod_src_compile
+
+ nvidia-drivers_make modprobe
+ nvidia-drivers_make persistenced
+ use X && nvidia-drivers_make xconfig
+
+ if use tools; then
+ nvidia-drivers_make settings
+ elif use static-libs; then
+ nvidia-drivers_make settings/src out/libXNVCtrl.a
+ fi
+}
+
+nvidia-drivers_libs_install() {
+ local libs=(
+ EGL_nvidia
+ GLESv1_CM_nvidia
+ GLESv2_nvidia
+ cuda
+ nvcuvid
+ nvidia-allocator
+ nvidia-eglcore
+ nvidia-encode
+ nvidia-glcore
+ nvidia-glsi
+ nvidia-glvkspirv
+ nvidia-ml
+ nvidia-opencl
+ nvidia-opticalflow
+ nvidia-ptxjitcompiler
+ nvidia-tls
+ )
+ use amd64 && libs+=( nvidia-compiler )
+
+ if use X; then
+ libs+=(
+ GLX_nvidia
+ vdpau_nvidia
+ )
+ if use amd64; then
+ libs+=(
+ nvidia-fbc
+ nvidia-ifr
+ )
+ fi
+ fi
+
+ local libdir=.
+ if multilib_is_native_abi; then
+ libs+=(
+ nvidia-cbl
+ nvidia-cfg
+ nvidia-rtcore
+ nvoptix
+ )
+ use amd64 && libs+=( nvidia-ngx )
+ else
+ libdir+=/32
+ fi
+
+ local lib soname
+ for lib in "${libs[@]}"; do
+ [[ ${lib:0:3} != lib ]] && lib=lib${lib}.so.${PV}
+
+ # auto-detect soname and create appropriate symlinks
+ soname=$(scanelf -qF'%S#F' "${lib}") || die "Scanning ${lib} failed"
+ if [[ ${soname} && ${soname} != ${lib} ]]; then
+ ln -s ${lib} ${libdir}/${soname} || die
+ fi
+ ln -s ${lib} ${libdir}/${lib%.so*}.so || die
+
+ dolib.so ${libdir}/${lib%.so*}*
+ done
+}
+
+src_install() {
+ if use driver; then
+ linux-mod_src_install
+
+ insinto /etc/modprobe.d
+ newins "${FILESDIR}"/nvidia-460.conf nvidia.conf
+ doins "${FILESDIR}"/nvidia-blacklist-nouveau.conf
+ doins "${FILESDIR}"/nvidia-rmmod.conf
+
+ # used for gpu verification with binpkgs (not kept)
+ insinto /usr/share/nvidia
+ doins supported-gpus/supported-gpus.json
+ fi
+
+ if use X; then
+ exeinto /usr/$(get_libdir)/xorg/modules/drivers
+ doexe nvidia_drv.so
+
+ exeinto /usr/$(get_libdir)/xorg/modules/extensions
+ newexe libglxserver_nvidia.so{.${PV},}
+
+ insinto /usr/share/X11/xorg.conf.d
+ newins {,50-}nvidia-drm-outputclass.conf
+
+ # vulkan icd uses libGLX_nvidia.so and so requires X
+ insinto /usr/share/vulkan/icd.d
+ doins nvidia_icd.json
+ insinto /usr/share/vulkan/implicit_layer.d
+ doins nvidia_layers.json
+ fi
+
+ insinto /usr/share/glvnd/egl_vendor.d
+ doins 10_nvidia.json
+
+ insinto /etc/OpenCL/vendors
+ doins nvidia.icd
+
+ insinto /etc/nvidia
+ newins nvidia-application-profiles{-${PV},}-rc
+
+ # install built helpers
+ nvidia-drivers_make modprobe install
+ # allow video group to load mods and create devs (bug #505092)
+ fowners root:video /usr/bin/nvidia-modprobe
+ fperms 4710 /usr/bin/nvidia-modprobe
+
+ nvidia-drivers_make persistenced install
+ newconfd "${FILESDIR}/nvidia-persistenced.confd" nvidia-persistenced
+ newinitd "${FILESDIR}/nvidia-persistenced.initd" nvidia-persistenced
+ systemd_dounit nvidia-persistenced.service
+
+ use X && nvidia-drivers_make xconfig install
+
+ if use tools; then
+ nvidia-drivers_make settings install
+ doicon nvidia-settings/doc/nvidia-settings.png
+ domenu nvidia-settings/doc/nvidia-settings.desktop
+
+ insinto /usr/share/nvidia
+ newins nvidia-application-profiles{-${PV},}-key-documentation
+
+ 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
+
+ # install prebuilt-only helpers
+ exeinto /opt/bin
+
+ doexe nvidia-cuda-mps-control
+ doman nvidia-cuda-mps-control.1
+ doexe nvidia-cuda-mps-server
+
+ doexe nvidia-debugdump
+ dobin nvidia-bug-report.sh
+
+ doexe nvidia-smi
+ doman nvidia-smi.1
+
+ # install prebuilt-only libraries
+ multilib_foreach_abi nvidia-drivers_libs_install
+
+ exeinto /lib/systemd/system-sleep
+ doexe nvidia
+ dobin nvidia-sleep.sh
+ systemd_dounit *.service
+
+ einstalldocs
+}
+
+pkg_preinst() {
+ use driver || return
+ linux-mod_pkg_preinst
+
+ # set video group id based on live system (bug #491414)
+ local g=$(getent group video | cut -d: -f3)
+ [[ ${g} ]] || die "Failed to determine video group id"
+ sed "s/PACKAGE/${PF}/;s/VIDEOGID/${g}/" \
+ -i "${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 "\"$(<${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
+
+ optfeature "wayland EGLStream with nvidia-drm.modeset=1" gui-libs/egl-wayland
+
+ if [[ -r /proc/driver/nvidia/version &&
+ $(grep -o ' [0-9.]* ' /proc/driver/nvidia/version) != " ${PV} " ]]; then
+ ewarn "Currently loaded NVIDIA modules do not match the newly installed"
+ ewarn "libraries and will lead to GPU-using application issues."
+ use driver && ewarn "The easiest way to fix this is to reboot."
+ fi
+
+ if [[ ${NV_LEGACY_MASK} ]]; then
+ ewarn "***** WARNING *****"
+ ewarn "You are installing a version of nvidia-drivers 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 ! [[ ${REPLACING_VERSIONS} && $(getent group video | cut -d: -f4) ]]; then
+ elog "***** WARNING *****"
+ elog "Users should be in the 'video' group to use NVIDIA devices."
+ elog "You can add yourself by using: gpasswd -a myuser video"
+ fi
+
+ if [[ ! ${REPLACING_VERSIONS} ]]; then
+ elog "For general information with using NVIDIA on Gentoo, please see:"
+ elog "https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers"
+ fi
+}