commit: a18fe769bc78b4bfb2072b8a41effdfcd817afcc Author: Ionen Wolkens <ionen <AT> gentoo <DOT> org> AuthorDate: Mon Mar 9 20:45:16 2026 +0000 Commit: Ionen Wolkens <ionen <AT> gentoo <DOT> org> CommitDate: Mon Mar 9 22:06:16 2026 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a18fe769
x11-drivers/nvidia-drivers: add 595.44.02:0/vulkan This came earlier than I expected considering the 595 branch is still beta (it does confirm that 595 will be a production branch though). Normally would also drop 580.94.18:0/vulkan at same time given we do not keep old versions for the vulkan branch (when hit by regressions, should just go back non-vulkan versions), but between legacy cards being dropped, and that some users are using this version to avoid regressions with xfce4 -- will keep it for an extended period to give time for users to adjust (probably until either 595 is stabilized or xfce4 issues are resolved, whichever comes first). Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org> x11-drivers/nvidia-drivers/Manifest | 2 + .../nvidia-drivers/nvidia-drivers-595.44.02.ebuild | 572 +++++++++++++++++++++ 2 files changed, 574 insertions(+) diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest index af9c71aff746..ff2144d324b2 100644 --- a/x11-drivers/nvidia-drivers/Manifest +++ b/x11-drivers/nvidia-drivers/Manifest @@ -11,6 +11,7 @@ DIST NVIDIA-Linux-x86_64-570.211.01.run 376192072 BLAKE2B 56a135681eba576377106b DIST NVIDIA-Linux-x86_64-580.126.18.run 396862844 BLAKE2B fa2d992d4f23beac7a10bc5d17695ee0c211e3afcb6fb9135f09b8eebed86db226b1cb4b9646917ab28f6127136b349fbc02deeecef2c5625f2be6a178cd268e SHA512 3007896838256c5534d7a04958f38f2837314b09d05e595966ba68789b0166fd8c1a574b29c8dd9ee5414822c9aebad9f9c7e5db777b811701fcac2b92245f0f DIST NVIDIA-Linux-x86_64-580.94.18.run 397082112 BLAKE2B c8ca38518debb4ed7bc26114aeb375acfe7da7f63056f08a9422f8e785f8488b1bfb9a66410985e8f883266f0befcd5bcd08e6bd4e0489c31bdf6374abe42bd1 SHA512 b1141f13cf2160e25004c9147328e60afb48b17866c907adfe1db6730ed50163fe5b8ff641d180c4b0420c0f47c0928585e52bf23c196d43a375d7a9466f8fe7 DIST NVIDIA-Linux-x86_64-590.48.01.run 416273526 BLAKE2B 57bc232f3d5cc52b3ba7c097e5c04b0e128947b34f75c8c7a75135ebbdda565dd9ae829f3707cfef35a9b8b554f2b46a50756f6b256a0f0280c22cf9ecefb2e1 SHA512 31fd82af707dbe9a6d3848766925386f5e91c5fae0a605819450eb8e5a5a52eaab3ae5cff50b4dd36bc5c32fe1aabc29a6a79438d6614988c7b08f509ef0da6d +DIST NVIDIA-Linux-x86_64-595.44.02.run 423123687 BLAKE2B 9912b54c6ec49d242fae5a0f257664470edabf8ec9a390d750aa579ab5720e3642f60f7212cdc01af4d223639ebcba193875980b5feafd14d6ad2cb7b60c7c11 SHA512 79799602343f95b59474f616df90c21e0494e00a698d82a79567b9eb14b44ab8eedc85c87d978a82b46743de705489ae27759046750cd5c6c0568a66b5b5ac91 DIST NVIDIA-Linux-x86_64-595.45.04.run 423188245 BLAKE2B 262bad2e9caf54c54968a5bdd3385d4ce725a4fe97537d92be20cf20c692c2d6fbaf875e8af5d62685158db6cafc22c656f33b08bfd0353cc137822211e90c2c SHA512 36907e0329564787e42eb598eff48e04c4058856bc95115cd5448eb4dfd351ac3d0df95b0fe5d2ef68e7ce9e848689955f40b3a9302d5231366efa89cfb21f7d DIST NVIDIA-kernel-module-source-535.288.01.tar.xz 12538144 BLAKE2B 597c58a62591e82b77fb29527d240bd2043b37439a1e7089ce5ab7ecb514ca3cae5be415aa4324f1156c08ddc1138c02e58337df5f38eaf7f19294773e4bcebc SHA512 b70d95af6737c36f8573d877a3473d38ecf3d7a4a35b899c38c1682888b455dcc60f6738ccee60a584477856b79dd25e6a10ffd1a4503c1d78a88902ba8329b4 DIST NVIDIA-kernel-module-source-570.211.01.tar.xz 17951900 BLAKE2B d40d2c1b4a92dfe8da95e1000413dfb484c9c96ad232dd5db14246378f6df8e73f04706592a536025c3d5512d5e663e7841de8bda782e3611b4b594b9b107ad4 SHA512 c988270d3aaa707310c3924de83eb5f5bdc4d022d1666eb3f41ed46eff35e98a765d4d6d34c22c02ac507016bed3c34af1da2e1befc285ec9158031a4a1447e4 @@ -53,3 +54,4 @@ DIST nvidia-xconfig-580.126.18.tar.bz2 111880 BLAKE2B 669b02a4dd3d3b08937f67f781 DIST nvidia-xconfig-590.48.01.tar.bz2 110986 BLAKE2B 6ec7f5eee2ca4c4a96f0607ac94ec3d491137a0e8750a6ae4c46feddced61f7a8b1eb77aa333008a69ceab7ad071671b7449bb2ed9ba285359fd1cb991a9c9b2 SHA512 e85dbd9ba5e056fb6f8a4618df35fa1692d0037e50122a5659ebda043a9b380fdf72aaa56f82b64e5525c36f429ed9bbd7f0e319c608f7c50355d47ab3b24077 DIST nvidia-xconfig-595.45.04.tar.bz2 111057 BLAKE2B 89cab70e2ed1aaf6af883966eed8597010497485ab6b019e8f237ab03c4a4a1bc37aab8ea24f67e96118f7315c21bf4b5056f97b188ce622b390919761e8b3d0 SHA512 85a64cf414f6a2ebf07466c7ecb9ca838810031f59c9fecfff3325fa4db0b37edeae7f6cf94a1127be074fe34af44e9ade06ea36d5c3764a0907d1706b49e8e4 DIST open-gpu-kernel-modules-580.94.18.tar.gz 23301123 BLAKE2B d05530e8dd763a5305a20fd7a47a99f5bb9088cee68fc023f00c94c48f6477b0db504fa95f3ff1262d21cd57b05af529341bebfc69ec3ce904ac0315d424b0f7 SHA512 71fb699c57061d226ddfc1e8974c9c3f50d68af651e0d56afb425482b35c8892c67f60f9a41bde86e3f6d93b15bb8661d1f57b55b0fc18c84a6b8775ca5328c4 +DIST open-gpu-kernel-modules-595.44.02.tar.gz 24795638 BLAKE2B 7254eaf7602339a9efbf8014de9f3f9377e38a52f3a0c3bfc9dd77f4c27beafd2a57178033e3b16505165cfbe2eca2ccb6e3b879c12089342d243329385b77c0 SHA512 125d5079927553c7104bb6cabf7f5582d73095b283a08f00604f02e87d8b0ecf23478b667a40208c66e396f0e3b15c90e1459ae97d41f5e2ab7161aec1ebb6b7 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-595.44.02.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-595.44.02.ebuild new file mode 100644 index 000000000000..e032212efd2b --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-595.44.02.ebuild @@ -0,0 +1,572 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop dot-a eapi9-pipestatus eapi9-ver flag-o-matic linux-mod-r1 +inherit readme.gentoo-r1 systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.19 +NV_PIN=595.45.04 + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://developer.nvidia.com/vulkan-driver/" +SRC_URI=" + https://developer.nvidia.com/downloads/vulkan-beta-${PV//.}-linux + -> NVIDIA-Linux-x86_64-${PV}.run + $(printf "https://download.nvidia.com/XFree86/%s/%s-${NV_PIN}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) + https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${PV}.tar.gz + -> open-gpu-kernel-modules-${PV}.tar.gz +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE=" + NVIDIA-2025 Apache-2.0 Boost-1.0 BSD BSD-2 GPL-2 MIT ZLIB + curl openssl public-domain +" +SLOT="0/vulkan" +KEYWORDS="-* ~amd64" +IUSE="+X abi_x86_32 abi_x86_64 persistenced powerd +static-libs +tools wayland" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +# egl-wayland2: nvidia currently ships both versions so, to ensure +# everything works properly, depend on both at same time for now +# (may use one or the other depending on setup) +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + >=gui-libs/egl-gbm-1.1.1-r2[abi_x86_32(-)?] + >=gui-libs/egl-wayland-1.1.13.1[abi_x86_32(-)?] + gui-libs/egl-wayland2[abi_x86_32(-)?] + X? ( gui-libs/egl-x11[abi_x86_32(-)?] ) + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + dev-util/vulkan-headers + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + app-alternatives/awk + sys-devel/m4 + virtual/pkgconfig +" + +# there is some non-prebuilt exceptions but rather not maintain a list +QA_PREBUILT="lib/firmware/* usr/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + # do early before linux-mod-r1 so can use chkconfig to setup CONFIG_CHECK + get_version + require_configured_kernel + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~DRM_FBDEV_EMULATION + ~SYSVIPC + ~!LOCKDEP + ~!PREEMPT_RT + ~!RANDSTRUCT_FULL + ~!RANDSTRUCT_PERFORMANCE + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + kernel_is -ge 6 11 && linux_chkconfig_present DRM_FBDEV_EMULATION && + CONFIG_CHECK+=" DRM_TTM_HELPER" + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + local drm_helper_msg="Cannot be directly selected in the kernel's config menus, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_QXL=m or + DRM_AMDGPU=m (among others, consult the kernel config's help), can + also use DRM_NOUVEAU=m as long as built as module *not* built-in." + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but is needed for wayland support, + tty takeover (e.g. for simpledrm), and config-less Xorg auto-detection. + ${drm_helper_msg}" + local ERROR_DRM_TTM_HELPER="CONFIG_DRM_TTM_HELPER: is not set but is needed to compile when using + kernel version 6.11.x or newer while DRM_FBDEV_EMULATION is set. + ${drm_helper_msg}" + local ERROR_DRM_FBDEV_EMULATION="CONFIG_DRM_FBDEV_EMULATION: is not set but is needed for + nvidia-drm.fbdev=1 support (see ${EPREFIX}/etc/modprobe.d/nvidia.conf), may + result in a blank console/tty." + local ERROR_PREEMPT_RT="CONFIG_PREEMPT_RT: is set but is unsupported by NVIDIA upstream and + will fail to build unless the env var IGNORE_PREEMPT_RT_PRESENCE=1 is + set. Please do not report issues if run into e.g. kernel panics while + ignoring this." + local randstruct_msg="is set but NVIDIA may be unstable with + it such as causing a kernel panic on shutdown, it is recommended to + disable with CONFIG_RANDSTRUCT_NONE=y (https://bugs.gentoo.org/969413 + -- please report if this appears fixed on NVIDIA's side so can remove + this warning)." + local ERROR_RANDSTRUCT_FULL="CONFIG_RANDSTRUCT_FULL: ${randstruct_msg}" + local ERROR_RANDSTRUCT_PERFORMANCE="CONFIG_RANDSTRUCT_PERFORMANCE: ${randstruct_msg}" + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${NV_PIN},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${NV_PIN},} || die + rm nvidia-settings && mv nvidia-settings{-${NV_PIN},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${NV_PIN},} || die + mv open-gpu-kernel-modules-${PV} kernel-module-source || die + + default + + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || 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 CXX LD OBJCOPY OBJDUMP PKG_CONFIG + + # extra flags for the libXNVCtrl.a static library + local xnvflags=-fPIC #840389 + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + # Same as uname -m. + local target_arch + case ${ARCH} in + amd64) target_arch=x86_64 ;; + arm64) target_arch=aarch64 ;; + *) die "Unrecognised architecture: ${ARCH}" ;; + esac + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + TARGET_ARCH="${target_arch}" + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + if use modules; then + local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} + + # environment flags are normally unused for modules, but nvidia uses + # them for building the formerly closed "blob" and it is a bit fragile + filter-flags -fno-plt #912949 + filter-lto + CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags + LDFLAGS=$(raw-ldflags) + + : video:kernel-module-source:kernel-module-source/kernel-open + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${_} ) + local modargs=( + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + TARGET_ARCH="${target_arch}" + + # kernel takes "x86" and "x86_64" as meaning the same, but nvidia + # makes the distinction (since 550.135) and is not happy with "x86" + # TODO?: it should be ok/better for tc-arch-kernel to do x86_64 + $(usev amd64 ARCH=x86_64) + ) + + # temporary workaround for bug #914468 + addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} + fi + + 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 + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + # pretend GTK+3 is available, not actually used (bug #880879) + emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ + -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 + [OPENGL_DATA]=/usr/share/nvidia + [VULKANSC_ICD_JSON]=/usr/share/vulkansc + [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=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + 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 + libnvidia-egl-wayland2 09_nvidia_wayland2 # gui-libs/egl-wayland2 + libnvidia-egl-xcb 20_nvidia_xcb.json # gui-libs/egl-x11 + libnvidia-egl-xlib 20_nvidia_xlib.json # gui-libs/egl-x11 + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + $(usev !powerd nvtopps) + 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 modules " + +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 additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + newins "${FILESDIR}"/nvidia-595.conf 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 + strip-lto-bytecode + + 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: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz} + pipestatus || die + 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]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/usr/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 + # avoid portage warning due to missing soname links in manifest + [[ ${m[0]} =~ ^libnvidia-ngx.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + # (sleep services skipped, obsoleted by NVreg_UseKernelSuspendNotifiers=1) + dobin nvidia-bug-report.sh + + insinto /usr/share/nvidia/files.d + doins sandboxutils-filelist.json + + # needed with >=systemd-256 or may fail to resume with some setups + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1072722 + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + insinto "${unitdir}"/systemd-homed.service.d + newins - 10-nvidia.conf <<-EOF + [Service] + Environment=SYSTEMD_HOME_LOCK_FREEZE_SESSION=false + EOF + insinto "${unitdir}"/systemd-suspend.service.d + newins systemd/system/systemd-suspend.service.d/nvidia-suspend-nofreeze.conf 10-nvidia.conf + dosym -r "${unitdir}"/systemd-{suspend,hibernate}.service.d/10-nvidia.conf + dosym -r "${unitdir}"/systemd-{suspend,hybrid-sleep}.service.d/10-nvidia.conf + dosym -r "${unitdir}"/systemd-{suspend,suspend-then-hibernate}.service.d/10-nvidia.conf + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # symlink non-versioned so nvidia-settings can use it even if misdetected + dosym nvidia-application-profiles-${PV}-key-documentation \ + ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation + + # don't attempt to strip firmware files (silences errors) + dostrip -x ${paths[FIRMWARE]} + + # sandbox issues with /dev/nvidiactl and others (bug #904292,#921578) + # are widespread and sometime affect revdeps of packages built with + # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, + # ebuilds should handle manually if need others or addwrite) + insinto /etc/sandbox.d + newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-caps:/dev/char"' + + # dracut does not use /etc/modprobe.d if hostonly=no, but want to make sure + # our settings are used for bug 932781#c8 and nouveau blacklist if either + # modules are included (however, just best-effort without initramfs regen) + if use modules; then + echo "install_items+=\" ${EPREFIX}/etc/modprobe.d/nvidia.conf \"" >> \ + "${ED}"/usr/lib/dracut/dracut.conf.d/10-${PN}.conf || die + fi +} + +pkg_preinst() { + use modules || return + + # 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() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $(</proc/driver/nvidia/version) != *" ${PV} "* ]]; then + ewarn "\nCurrently loaded NVIDIA modules do not match the newly installed" + ewarn "libraries and may prevent launching GPU-accelerated applications." + if use modules; then + ewarn "Easiest way to fix this is normally to reboot. If still run into issues" + ewarn "(e.g. API mismatch messages in the \`dmesg\` output), please verify" + ewarn "that the running kernel is ${KV_FULL} and that (if used) the" + ewarn "initramfs does not include NVIDIA modules (or at least, not old ones)." + fi + fi + + if [[ $(</proc/cmdline) == *slub_debug=[!-]* ]]; then + ewarn "\nDetected 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 "\n***WARNING***" + ewarn "\nYou 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[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + if ver_replacing -lt 590; then + elog "\n>=${PN}-590 has changes that may or may not need attention:" + elog "1. support for Pascal, Maxwell, and Volta cards has been dropped" + elog " (if affected, there should be a another message about this above)" + elog "2. nvidia-drm.modeset=1 is now default regardless of USE=wayland" + elog "3. nvidia-drm.fbdev=1 is now also tentatively default to match upstream" + elog "(2+3 were also later changed in >=580.126.09-r1, may already be in-use)" + elog "See ${EROOT}/etc/modprobe.d/nvidia.conf to modify settings if needed," + elog "fbdev=1 *could* cause issues for the console display with some setups." + fi + + if ver_replacing -lt 595; then + elog "\n>=${PN}-595 has changes that may or may not need attention:" + elog "1. USE=kernel-open was removed and is now always enabled. If for some" + elog " reason you really need the closed variant (e.g. Runtime D3 on Turing" + elog " GPUs), please use LTS 580.xx instead as Gentoo has no intention to" + elog " support both variants anymore going forward" + elog "2. systemd/elogind sleep services (nvidia-sleep.sh) were tentatively" + elog " removed and replaced by setting NVreg_UseKernelSuspendNotifiers=1 in" + elog " ${EROOT}/etc/modprobe.d/nvidia.conf. If using a non-default custom" + elog " nvidia.conf, please ensure the option is set." + elog " Note: considered experimental at the moment and may cause the" + elog " kernel to crash on suspend, *could* be reverted by the time a" + elog " non-beta 595.xx version is keyworded if has not improved yet." + elog "3. nvidia-drm.modeset=1 was removed from nvidia.conf because it is now" + elog " default enabled regardless (new NVIDIA default)" + fi +}
