From a5e9015d933df761f5d31a4ec8ec6b41ebbf46ed Mon Sep 17 00:00:00 2001 From: Rick Peters Date: Thu, 1 Oct 2026 17:19:23 +0200 Subject: [PATCH] fix: NVIDIA fix handles Limine's += command line, underscore spelling; hardware test sets SCRIPT_DIR --- CHANGELOG.md | 1 + lib/nvidia.sh | 10 ++++++---- tests/nvidia-hardware-test.sh | 2 ++ tests/nvidia-test.sh | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72cd481..4107e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ one per merged pull request. - **test: tests/nvidia-hardware-test.sh for a real NVIDIA PC: check (read-only state of the detection, the live nvidia_drm modeset/fbdev, versions), apply, and visual (was the gaming mode picture clean), with a report file to paste** - **fix: the NVIDIA modules are loaded early only while every installed kernel has them, decided again at every kernel or driver change by a pacman hook (steamify-nvidia-initramfs): a later kernel without the modules (another kernel, a failed DKMS build, a downgrade) no longer makes its initramfs and Limine boot entry fail** - **feat: the NVIDIA fix is only for RTX 20 series or newer, decided like the VRAM booster does (vram_nvidia_legacy_id: chwd's legacy card lists); older cards are left alone** +- **fix: the NVIDIA fix also edits Limine's `KERNEL_CMDLINE[default]+="..."` line (CachyOS writes that form; the fix found no line to edit and stopped) and counts `nvidia_drm.modeset=1` (underscore) as already set; tests/nvidia-hardware-test.sh sets `SCRIPT_DIR` (the hook script was read from `/patches`)** ## 2.9.6 - 2026-09-30 diff --git a/lib/nvidia.sh b/lib/nvidia.sh index 79518d7..dd0a817 100644 --- a/lib/nvidia.sh +++ b/lib/nvidia.sh @@ -50,9 +50,11 @@ nvidia_boot_file() { nvidia_param_set() { # 0 when $1 (e.g. nvidia-drm.modeset=1) is on the kernel command line or # already in the boot loader's file (not booted yet). - local f; f="$(nvidia_boot_file)" - grep -qw -- "$1" /proc/cmdline 2>/dev/null || - { [[ -n "$f" ]] && grep -qw -- "$1" "$f" 2>/dev/null; } + # The kernel treats "nvidia_drm" and "nvidia-drm" alike: CachyOS' own + # setup may already have written the underscore spelling. + local f re; f="$(nvidia_boot_file)"; re="${1//nvidia-drm/nvidia[-_]drm}" + grep -qwE -- "$re" /proc/cmdline 2>/dev/null || + { [[ -n "$f" ]] && grep -qwE -- "$re" "$f" 2>/dev/null; } } nvidia_params_missing() { @@ -116,7 +118,7 @@ nvidia_enable() { backup_file "$f" case "$f" in */limine) - sudo sed -i -E "s/^(KERNEL_CMDLINE\[default\]=\"[^\"]*)\"/\1 $NVIDIA_PARAMS\"/" "$f" ;; + sudo sed -i -E "s/^(KERNEL_CMDLINE\[default\]\+?=\"[^\"]*)\"/\1 $NVIDIA_PARAMS\"/" "$f" ;; */sdboot-manage.conf) sudo sed -i -E "s/^(LINUX_OPTIONS=\"[^\"]*)\"/\1 $NVIDIA_PARAMS\"/" "$f" ;; */grub) diff --git a/tests/nvidia-hardware-test.sh b/tests/nvidia-hardware-test.sh index 8bcde84..dac209c 100644 --- a/tests/nvidia-hardware-test.sh +++ b/tests/nvidia-hardware-test.sh @@ -6,6 +6,8 @@ # bash tests/nvidia-hardware-test.sh visual after trying gaming mode: was the picture clean? (asks you) # Every run appends to ~/steamify-nvidia-report.txt: paste that file when asking for help. cd "$(dirname "$0")/.." || exit 1 +# patch_file (lib/common.sh) reads the hook script from $SCRIPT_DIR/patches. +SCRIPT_DIR="$PWD" REPORT="${NVIDIA_REPORT:-$HOME/steamify-nvidia-report.txt}" source lib/common.sh; source lib/hdmi-refresh.sh; source lib/vram-booster.sh; source lib/nvidia.sh mode="${1:-check}" diff --git a/tests/nvidia-test.sh b/tests/nvidia-test.sh index 4f17498..52cee29 100644 --- a/tests/nvidia-test.sh +++ b/tests/nvidia-test.sh @@ -38,9 +38,11 @@ FAKE_DRIVER=0; check "skips when the driver isn't installed" '! nvidia_present' FAKE_DRIVER=1; NVIDIA_DRM_DIR="$T/none"; check "skips without an NVIDIA GPU" '! nvidia_present' NVIDIA_DRM_DIR="$T/drm" -for loader in limine sdboot grub; do +for loader in limine limineplus sdboot grub; do case $loader in limine) F="$T/limine"; printf 'KERNEL_CMDLINE[default]="quiet splash"\n' > "$F" ;; + # CachyOS writes its line as "+=" and may already have nvidia_drm.modeset=1 in it. + limineplus) F="$T/limine"; printf 'KERNEL_CMDLINE[default]+="quiet splash nvidia_drm.modeset=1"\n' > "$F" ;; sdboot) F="$T/sdboot-manage.conf"; printf 'LINUX_OPTIONS="quiet splash"\n' > "$F" ;; grub) F="$T/grub"; printf 'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"\n' > "$F" ;; esac