From c12ca2f5d18fd15f09cec098af785f06ad26690a Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 18 Aug 2025 08:59:26 +0200 Subject: [PATCH] fix: nvidia detect not available --- fresh-install/detect_gpu.sh | 0 fresh-install/install_nvidia_driver.sh | 35 ++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) mode change 100644 => 100755 fresh-install/detect_gpu.sh diff --git a/fresh-install/detect_gpu.sh b/fresh-install/detect_gpu.sh old mode 100644 new mode 100755 diff --git a/fresh-install/install_nvidia_driver.sh b/fresh-install/install_nvidia_driver.sh index e444978..ff174b7 100755 --- a/fresh-install/install_nvidia_driver.sh +++ b/fresh-install/install_nvidia_driver.sh @@ -16,17 +16,35 @@ _build_aur_pkg() { } _choose_nvidia_pkg() { - local have_linux have_linux_lts multiple_kernels driver_pkg prefer_open + local have_linux have_linux_lts multiple_kernels driver_pkg prefer_open detect_out legacy_detected=0 prefer_open=${NVIDIA_PREFER_OPEN:-1} pacman -Qq | grep -qx linux && have_linux=1 || have_linux=0 pacman -Qq | grep -qx linux-lts && have_linux_lts=1 || have_linux_lts=0 if [ $((have_linux + have_linux_lts)) -gt 1 ]; then multiple_kernels=1; else multiple_kernels=0; fi - if ! command -v nvidia-detect >/dev/null 2>&1; then yes | sudo pacman -Sy --noconfirm nvidia-detect || true; fi - local detect_out="$(nvidia-detect 2>/dev/null || true)" - if echo "$detect_out" | grep -q '470'; then driver_pkg='nvidia-470xx-dkms'; - elif echo "$detect_out" | grep -q '390'; then driver_pkg='nvidia-390xx-dkms'; - elif echo "$detect_out" | grep -q '340'; then driver_pkg='nvidia-340xx-dkms'; - else + + # Optionally skip attempting to install nvidia-detect (some minimal repo setups don't have it yet) + if [ -z "${NVIDIA_SKIP_DETECT:-}" ] && ! command -v nvidia-detect >/dev/null 2>&1; then + if pacman -Si nvidia-detect >/dev/null 2>&1; then + echo "Attempting to install helper utility: nvidia-detect" >&2 + # Use --needed to avoid forcing refresh (& avoid partial upgrade semantics with -Sy) + yes | sudo pacman -S --needed --noconfirm nvidia-detect || echo "nvidia-detect install failed (continuing with heuristic)" >&2 + else + echo "nvidia-detect not present in enabled repos; using heuristic selection." >&2 + fi + fi + + if command -v nvidia-detect >/dev/null 2>&1; then + detect_out="$(nvidia-detect 2>/dev/null || true)" + fi + + if [ -n "$detect_out" ]; then + if echo "$detect_out" | grep -q '470'; then driver_pkg='nvidia-470xx-dkms'; legacy_detected=1; fi + if echo "$detect_out" | grep -q '390'; then driver_pkg='nvidia-390xx-dkms'; legacy_detected=1; fi + if echo "$detect_out" | grep -q '340'; then driver_pkg='nvidia-340xx-dkms'; legacy_detected=1; fi + fi + + if [ "$legacy_detected" = 0 ]; then + # Heuristic modern driver selection if [ "$multiple_kernels" = 1 ]; then if [ "$prefer_open" = 1 ] && pacman -Si nvidia-open-dkms >/dev/null 2>&1; then driver_pkg='nvidia-open-dkms'; else driver_pkg='nvidia-dkms'; fi else @@ -36,7 +54,10 @@ _choose_nvidia_pkg() { if [ "$prefer_open" = 1 ] && pacman -Si nvidia-open >/dev/null 2>&1; then driver_pkg='nvidia-open'; else driver_pkg='nvidia'; fi fi fi + else + echo "Legacy NVIDIA generation detected via nvidia-detect output; choosing $driver_pkg" >&2 fi + echo "$driver_pkg" }