| 7 |
7 |
inherit desktop dot-a eapi9-pipestatus eapi9-ver flag-o-matic linux-mod-r1
|
| 8 |
8 |
inherit readme.gentoo-r1 systemd toolchain-funcs unpacker user-info
|
| 9 |
9 |
|
| 10 |
|
MODULES_KERNEL_MAX=7.2
|
|
10 |
MODULES_KERNEL_MAX=7.1
|
| 11 |
11 |
NV_URI="https://download.nvidia.com/XFree86/"
|
| 12 |
12 |
|
| 13 |
13 |
DESCRIPTION="NVIDIA Accelerated Graphics Driver"
|
| ... | ... | |
| 28 |
28 |
"
|
| 29 |
29 |
SLOT="0/${PV%%.*}"
|
| 30 |
30 |
KEYWORDS="-* amd64 ~arm64"
|
| 31 |
|
IUSE="
|
| 32 |
|
+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd
|
| 33 |
|
+static-libs +tools wayland
|
| 34 |
|
"
|
|
31 |
IUSE="+X abi_x86_32 abi_x86_64 persistenced powerd +static-libs +tools wayland"
|
| 35 |
32 |
|
| 36 |
33 |
COMMON_DEPEND="
|
| 37 |
34 |
acct-group/video
|
| ... | ... | |
| 54 |
51 |
x11-libs/pango
|
| 55 |
52 |
)
|
| 56 |
53 |
"
|
|
54 |
# egl-wayland2: nvidia currently ships both versions so, to ensure
|
|
55 |
# everything works properly, depend on both at same time for now
|
|
56 |
# (may use one or the other depending on setup)
|
| 57 |
57 |
RDEPEND="
|
| 58 |
58 |
${COMMON_DEPEND}
|
| 59 |
59 |
|| (
|
| ... | ... | |
| 70 |
70 |
wayland? (
|
| 71 |
71 |
>=gui-libs/egl-gbm-1.1.1-r2[abi_x86_32(-)?]
|
| 72 |
72 |
>=gui-libs/egl-wayland-1.1.13.1[abi_x86_32(-)?]
|
|
73 |
gui-libs/egl-wayland2[abi_x86_32(-)?]
|
| 73 |
74 |
X? ( gui-libs/egl-x11[abi_x86_32(-)?] )
|
| 74 |
75 |
)
|
| 75 |
76 |
"
|
| ... | ... | |
| 101 |
102 |
PATCHES=(
|
| 102 |
103 |
"${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch
|
| 103 |
104 |
"${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch
|
| 104 |
|
"${FILESDIR}"/nvidia-drivers-580.159.03-null-deref.patch
|
| 105 |
105 |
)
|
| 106 |
106 |
|
| 107 |
107 |
pkg_setup() {
|
| ... | ... | |
| 114 |
114 |
local CONFIG_CHECK="
|
| 115 |
115 |
PROC_FS
|
| 116 |
116 |
~DRM_KMS_HELPER
|
|
117 |
~DRM_FBDEV_EMULATION
|
| 117 |
118 |
~SYSVIPC
|
| 118 |
119 |
~!LOCKDEP
|
| 119 |
120 |
~!PREEMPT_RT
|
| ... | ... | |
| 126 |
127 |
kernel_is -ge 6 11 && linux_chkconfig_present DRM_FBDEV_EMULATION &&
|
| 127 |
128 |
CONFIG_CHECK+=" DRM_TTM_HELPER"
|
| 128 |
129 |
|
| 129 |
|
linux_chkconfig_present DRM_KMS_HELPER &&
|
| 130 |
|
CONFIG_CHECK+=" DRM_FBDEV_EMULATION"
|
| 131 |
|
|
| 132 |
|
use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827
|
| 133 |
|
|
| 134 |
130 |
local drm_helper_msg="Cannot be directly selected in the kernel's config menus, and may need
|
| 135 |
131 |
selection of a DRM device even if unused, e.g. CONFIG_DRM_QXL=m or
|
| 136 |
132 |
DRM_AMDGPU=m (among others, consult the kernel config's help), can
|
| 137 |
133 |
also use DRM_NOUVEAU=m as long as built as module *not* built-in."
|
| 138 |
|
local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but is needed for nvidia-drm.modeset=1
|
| 139 |
|
support (see ${EPREFIX}/etc/modprobe.d/nvidia.conf) which is needed for wayland
|
| 140 |
|
and for config-less Xorg auto-detection.
|
|
134 |
local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but is needed for wayland support,
|
|
135 |
tty takeover (e.g. for simpledrm), and config-less Xorg auto-detection.
|
| 141 |
136 |
${drm_helper_msg}"
|
| 142 |
137 |
local ERROR_DRM_TTM_HELPER="CONFIG_DRM_TTM_HELPER: is not set but is needed to compile when using
|
| 143 |
138 |
kernel version 6.11.x or newer while DRM_FBDEV_EMULATION is set.
|
| 144 |
139 |
${drm_helper_msg}"
|
| 145 |
|
local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open.
|
| 146 |
|
Cannot be directly selected in the kernel's menuconfig, and may need
|
| 147 |
|
selection of another option that requires it such as CONFIG_AMD_IOMMU=y,
|
| 148 |
|
or DRM_I915=m (among others, consult the kernel config's help)."
|
|
140 |
local ERROR_DRM_FBDEV_EMULATION="CONFIG_DRM_FBDEV_EMULATION: is not set but is needed for
|
|
141 |
nvidia-drm.fbdev=1 support (see ${EPREFIX}/etc/modprobe.d/nvidia.conf), may
|
|
142 |
result in a blank console/tty."
|
| 149 |
143 |
local ERROR_PREEMPT_RT="CONFIG_PREEMPT_RT: is set but is unsupported by NVIDIA upstream and
|
| 150 |
144 |
will fail to build unless the env var IGNORE_PREEMPT_RT_PRESENCE=1 is
|
| 151 |
145 |
set. Please do not report issues if run into e.g. kernel panics while
|
| ... | ... | |
| 164 |
158 |
|
| 165 |
159 |
default
|
| 166 |
160 |
|
| 167 |
|
# prevent detection of incomplete kernel DRM support (bug #603818)
|
| 168 |
|
sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \
|
| 169 |
|
-i kernel{,-module-source/kernel-open}/conftest.sh || die
|
| 170 |
|
|
| 171 |
161 |
sed 's/__USER__/nvpd/' \
|
| 172 |
162 |
nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
|
| 173 |
163 |
> "${T}"/nvidia-persistenced.service || die
|
| ... | ... | |
| 210 |
200 |
if use modules; then
|
| 211 |
201 |
local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS}
|
| 212 |
202 |
|
| 213 |
|
local modlistargs=video:kernel
|
| 214 |
|
if use kernel-open; then
|
| 215 |
|
modlistargs+=-module-source:kernel-module-source/kernel-open
|
| 216 |
|
|
| 217 |
|
# environment flags are normally unused for modules, but nvidia
|
| 218 |
|
# uses it for building the "blob" and it is a bit fragile
|
| 219 |
|
filter-flags -fno-plt #912949
|
| 220 |
|
filter-lto
|
| 221 |
|
CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags
|
| 222 |
|
|
| 223 |
|
LDFLAGS=$(raw-ldflags)
|
| 224 |
|
|
| 225 |
|
# the "blob" uses C++ which is an issue if there is debug symbols
|
| 226 |
|
# when running pahole, there is a pahole.sh wrapper that tries to
|
| 227 |
|
# exclude C++ but it did not seem to be enough last time tried
|
| 228 |
|
linux_chkconfig_present DEBUG_INFO_BTF_MODULES && append-flags -g0
|
| 229 |
|
fi
|
|
203 |
# environment flags are normally unused for modules, but nvidia uses
|
|
204 |
# them for building the formerly closed "blob" and it is a bit fragile
|
|
205 |
filter-flags -fno-plt #912949
|
|
206 |
filter-lto
|
|
207 |
CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags
|
|
208 |
LDFLAGS=$(raw-ldflags)
|
|
209 |
|
|
210 |
# the "blob" uses C++ which is an issue if there is debug symbols
|
|
211 |
# when running pahole, there is a pahole.sh wrapper that tries to
|
|
212 |
# exclude C++ but it did not seem to be enough last time tried
|
|
213 |
linux_chkconfig_present DEBUG_INFO_BTF_MODULES && append-flags -g0
|
| 230 |
214 |
|
| 231 |
|
local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} )
|
|
215 |
: video:kernel-module-source:kernel-module-source/kernel-open
|
|
216 |
local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${_} )
|
| 232 |
217 |
local modargs=(
|
| 233 |
218 |
IGNORE_CC_MISMATCH=yes NV_VERBOSE=1
|
| 234 |
219 |
SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}"
|
| ... | ... | |
| 291 |
276 |
libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source
|
| 292 |
277 |
libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm
|
| 293 |
278 |
libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland
|
|
279 |
libnvidia-egl-wayland2 09_nvidia_wayland2 # gui-libs/egl-wayland2
|
| 294 |
280 |
libnvidia-egl-xcb 20_nvidia_xcb.json # gui-libs/egl-x11
|
| 295 |
281 |
libnvidia-egl-xlib 20_nvidia_xlib.json # gui-libs/egl-x11
|
| 296 |
282 |
libnvidia-pkcs11.so # using the openssl3 version instead
|
| ... | ... | |
| 338 |
324 |
Note that without USE=abi_x86_32 on ${PN}, 32bit applications
|
| 339 |
325 |
(typically using wine / steam) will not be able to use GPU acceleration.")
|
| 340 |
326 |
|
| 341 |
|
Be warned that USE=kernel-open may need to be either enabled or
|
| 342 |
|
disabled for certain cards to function:
|
| 343 |
|
- GTX 50xx (blackwell) and higher require it to be enabled
|
| 344 |
|
- GTX 1650 and higher (pre-blackwell) should work either way
|
| 345 |
|
- Older cards require it to be disabled
|
| 346 |
|
|
| 347 |
327 |
For additional information or for troubleshooting issues, please see
|
| 348 |
328 |
https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own
|
| 349 |
329 |
documentation that is installed alongside this README."
|
| ... | ... | |
| 353 |
333 |
linux-mod-r1_src_install
|
| 354 |
334 |
|
| 355 |
335 |
insinto /etc/modprobe.d
|
| 356 |
|
newins "${FILESDIR}"/nvidia-580.conf nvidia.conf
|
|
336 |
newins "${FILESDIR}"/nvidia-595.conf nvidia.conf
|
| 357 |
337 |
|
| 358 |
338 |
# used for gpu verification with binpkgs (not kept, see pkg_preinst)
|
| 359 |
339 |
insinto /usr/share/nvidia
|
| ... | ... | |
| 444 |
424 |
insopts -m0644 # reset
|
| 445 |
425 |
|
| 446 |
426 |
# MODULE:installer non-skipped extras
|
| 447 |
|
: "$(systemd_get_sleepdir)"
|
| 448 |
|
exeinto "${_#"${EPREFIX}"}"
|
| 449 |
|
doexe systemd/system-sleep/nvidia
|
| 450 |
|
dobin systemd/nvidia-sleep.sh
|
| 451 |
|
systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend,suspend-then-hibernate}.service
|
| 452 |
|
|
|
427 |
# (sleep services skipped, obsoleted by NVreg_UseKernelSuspendNotifiers=1)
|
| 453 |
428 |
dobin nvidia-bug-report.sh
|
| 454 |
429 |
|
| 455 |
430 |
insinto /usr/share/nvidia/files.d
|
| 456 |
431 |
doins sandboxutils-filelist.json
|
| 457 |
432 |
|
| 458 |
|
# MODULE:powerd extras
|
| 459 |
|
if use powerd; then
|
| 460 |
|
newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117
|
| 461 |
|
systemd_dounit systemd/system/nvidia-powerd.service
|
| 462 |
|
|
| 463 |
|
insinto /usr/share/dbus-1/system.d
|
| 464 |
|
doins nvidia-dbus.conf
|
| 465 |
|
fi
|
| 466 |
|
|
| 467 |
|
# enabling is needed for sleep to work properly and little reason not to do
|
| 468 |
|
# it unconditionally for a better user experience
|
| 469 |
|
: "$(systemd_get_systemunitdir)"
|
| 470 |
|
local unitdir=${_#"${EPREFIX}"}
|
| 471 |
|
# not using relative symlinks to match systemd's own links
|
| 472 |
|
dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service
|
| 473 |
|
dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service
|
| 474 |
|
dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service
|
| 475 |
|
dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service
|
| 476 |
|
dosym {"${unitdir}",/etc/systemd/system/systemd-suspend-then-hibernate.service.wants}/nvidia-suspend-then-hibernate.service
|
| 477 |
|
dosym {"${unitdir}",/etc/systemd/system/systemd-suspend-then-hibernate.service.wants}/nvidia-resume.service
|
| 478 |
|
# also add a custom elogind hook to do the equivalent of the above
|
| 479 |
|
exeinto /usr/lib/elogind/system-sleep
|
| 480 |
|
newexe "${FILESDIR}"/system-sleep.elogind nvidia
|
| 481 |
|
# <elogind-255.5 used a different path (bug #939216), keep a compat symlink
|
| 482 |
|
# TODO: cleanup after 255.5 been stable for a few months
|
| 483 |
|
dosym {/usr/lib,/"${libdir}"}/elogind/system-sleep/nvidia
|
| 484 |
|
|
| 485 |
433 |
# needed with >=systemd-256 or may fail to resume with some setups
|
| 486 |
434 |
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1072722
|
|
435 |
: "$(systemd_get_systemunitdir)"
|
|
436 |
local unitdir=${_#"${EPREFIX}"}
|
| 487 |
437 |
insinto "${unitdir}"/systemd-homed.service.d
|
| 488 |
438 |
newins - 10-nvidia.conf <<-EOF
|
| 489 |
439 |
[Service]
|
| 490 |
440 |
Environment=SYSTEMD_HOME_LOCK_FREEZE_SESSION=false
|
| 491 |
441 |
EOF
|
| 492 |
442 |
insinto "${unitdir}"/systemd-suspend.service.d
|
| 493 |
|
newins - 10-nvidia.conf <<-EOF
|
| 494 |
|
[Service]
|
| 495 |
|
Environment=SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false
|
| 496 |
|
EOF
|
|
443 |
newins systemd/system/systemd-suspend.service.d/nvidia-suspend-nofreeze.conf 10-nvidia.conf
|
| 497 |
444 |
dosym -r "${unitdir}"/systemd-{suspend,hibernate}.service.d/10-nvidia.conf
|
| 498 |
445 |
dosym -r "${unitdir}"/systemd-{suspend,hybrid-sleep}.service.d/10-nvidia.conf
|
| 499 |
446 |
dosym -r "${unitdir}"/systemd-{suspend,suspend-then-hibernate}.service.d/10-nvidia.conf
|
| 500 |
447 |
|
|
448 |
# MODULE:powerd extras
|
|
449 |
if use powerd; then
|
|
450 |
newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117
|
|
451 |
systemd_dounit systemd/system/nvidia-powerd.service
|
|
452 |
|
|
453 |
insinto /usr/share/dbus-1/system.d
|
|
454 |
doins nvidia-dbus.conf
|
|
455 |
fi
|
|
456 |
|
| 501 |
457 |
# symlink non-versioned so nvidia-settings can use it even if misdetected
|
| 502 |
458 |
dosym nvidia-application-profiles-${PV}-key-documentation \
|
| 503 |
459 |
${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation
|
| ... | ... | |
| 522 |
478 |
}
|
| 523 |
479 |
|
| 524 |
480 |
pkg_preinst() {
|
| 525 |
|
has_version "${CATEGORY}/${PN}[kernel-open]" && NV_HAD_KERNEL_OPEN=
|
| 526 |
|
|
| 527 |
481 |
use modules || return
|
| 528 |
482 |
|
| 529 |
483 |
# set video group id based on live system (bug #491414)
|
| ... | ... | |
| 584 |
538 |
ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau"
|
| 585 |
539 |
fi
|
| 586 |
540 |
|
| 587 |
|
if use kernel-open && use modules && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then
|
| 588 |
|
ewarn "\nOpen source variant of ${PN} was selected, note that it requires"
|
| 589 |
|
ewarn "Turing/Ampere+ GPUs (aka GTX 1650+). Try disabling if run into issues."
|
| 590 |
|
ewarn "Also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html"
|
| 591 |
|
fi
|
| 592 |
|
|
| 593 |
|
if ver_replacing -lt 580.126.09-r1; then
|
| 594 |
|
elog "\n>=nvidia-drivers-580.126.09-r1 changes some defaults that may or may"
|
| 595 |
|
elog "not need attention:"
|
| 596 |
|
elog "1. nvidia-drm.modeset=1 is now default regardless of USE=wayland"
|
| 597 |
|
elog "2. nvidia-drm.fbdev=1 is now also tentatively default to match upstream"
|
| 598 |
|
elog "See ${EROOT}/etc/modprobe.d/nvidia.conf to modify settings if needed,"
|
| 599 |
|
elog "fbdev=1 *could* cause issues for the console display with some setups."
|
|
541 |
if ver_replacing -lt 595; then
|
|
542 |
elog "\n>=${PN}-595 has changes that may or may not need attention:"
|
|
543 |
elog "1. USE=kernel-open was removed and is now always enabled. If for some"
|
|
544 |
elog " reason you really need the closed variant (e.g. Runtime D3 on Turing"
|
|
545 |
elog " GPUs), please use LTS 580.xx instead as Gentoo has no intention to"
|
|
546 |
elog " support both variants anymore going forward"
|
|
547 |
elog "2. systemd/elogind sleep services (nvidia-sleep.sh) were tentatively"
|
|
548 |
elog " removed and replaced by setting NVreg_UseKernelSuspendNotifiers=1 in"
|
|
549 |
elog " ${EROOT}/etc/modprobe.d/nvidia.conf. If using a non-default custom"
|
|
550 |
elog " nvidia.conf, please ensure the option is set. Also, systemd users"
|
|
551 |
elog " may want to ensure that they do not have old sleep/suspend/resume"
|
|
552 |
elog " *nvidia* files in ${EROOT}/etc/systemd to avoid potential issues."
|
|
553 |
elog "3. nvidia-drm.modeset=1 was removed from nvidia.conf because it is now"
|
|
554 |
elog " default enabled regardless (new NVIDIA default)"
|
| 600 |
555 |
fi
|
| 601 |
556 |
}
|