Use smart NVIDIA module loading on boot

This not only saves users from hard choices at boot, but also saves us
from a bunch of workarounds to avoid conflicts with Nouveau.

Should fix most of the black screen issues when booting ISO (but it's
not for sure...)

Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
This commit is contained in:
Vasiliy Stelmachenok authored and Vladislav Nepogodin committed 2025-05-23 19:57:42 +04:00
1 parent d1d59bb234
commit ff92ea3b49
5 files changed
+48 -3

No files matched your search

@@ -0,0 +1,6 @@
# Forwards all NVIDIA module load requests to a "smart" loader that selects
# correct version of the module depending on used hardware.
install nvidia /usr/local/bin/nvidia-module-loader
install nvidia_drm /usr/local/bin/nvidia-module-loader
install nvidia_uvm /usr/local/bin/nvidia-module-loader
install nvidia_modeset /usr/local/bin/nvidia-module-loader
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Quick pass if one of the modules is already loaded.
if [[ -e /sys/module/nvidia || -e /sys/module/nouveau ]]; then
exit 0
fi
# Using "install" in modprobe seems to result in no dependency resolving for
# modules, so we have to manually set the order in which all modules are loaded
# at once.
load_nvidia_modules() {
local pkgname="$1"
# Load some basic dependencies of nvidia modules
modprobe video
modprobe drm_ttm_helper
modprobe drm_kms_helper
for module in nvidia nvidia-modeset nvidia-drm nvidia-uvm; do
modprobe --ignore-install "/usr/share/modules/${pkgname}/${module}.ko.zst"
done
}
# Load compatible version of NVIDIA modules for current hardware
if chwd --list | awk '{ if($2 == "nouveau" || $2 == "nvidia-dkms-390xx" || $2 == "nvidia-dkms-470xx") f=1 } END {exit (f == 1) ? 0 : 1 }'; then
modprobe nouveau
elif chwd --list | awk '{ if($2 == "nvidia-dkms") f=1 } END {exit (f == 1) ? 0 : 1 }'; then
load_nvidia_modules linux-cachyos-nvidia
elif chwd --list | awk '{ if($2 == "nvidia-open-dkms") f=1 } END {exit (f == 1) ? 0 : 1 }'; then
load_nvidia_modules linux-cachyos-nvidia-open
fi
# Otherwise, do a fallback to nouveau anyway
if [[ ! -e /sys/module/nouveau && ! -e /sys/module/nvidia ]]; then
modprobe nouveau
fi
+1 -1
View File
@@ -79,7 +79,6 @@ libusb-compat
libwnck3
linux-atm
linux-cachyos
linux-cachyos-nvidia-open
linux-cachyos-zfs
linux-firmware
linux-firmware-marvell
@@ -115,6 +114,7 @@ nss-mdns
ntfs-3g
ntp
nvidia-utils
nvidia-module-extractor
nvme-cli
occt
open-iscsi
+5 -2
View File
@@ -73,9 +73,12 @@ LocalFileSigLevel = Optional
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[cachyos]
SigLevel = Optional TrustAll
# Yeah, that's dumb, but we have to do it for nvidia-module-extractor hook,
# since mkarchiso doesn't import the keys inside rootfs for cachyos repo before
# creating squashfs. The right solution here would be to find a way to import
# the keys properly.
SigLevel = Never
Server = https://mirror.cachyos.org/repo/$arch/$repo
#[core-testing]
+1
View File
@@ -32,4 +32,5 @@ file_permissions=(
["/usr/local/bin/removeun"]="0:0:755"
["/usr/local/bin/removeun-online"]="0:0:755"
["/usr/local/bin/prepare-live-desktop.sh"]="0:0:755"
["/usr/local/bin/nvidia-module-loader"]="0:0:755"
)