mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Merge pull request #3956 from ashddev/fix/nvidia-legacy-driver-for-older-gpus
fix(nvidia): install legacy NVIDIA driver on older GPUs
This commit is contained in:
@@ -1,80 +1,40 @@
|
||||
# ==============================================================================
|
||||
# Hyprland NVIDIA Setup Script for Arch Linux
|
||||
# ==============================================================================
|
||||
# This script automates the installation and configuration of NVIDIA drivers
|
||||
# for use with Hyprland on Arch Linux, following the official Hyprland wiki.
|
||||
#
|
||||
# Author: https://github.com/Kn0ax
|
||||
#
|
||||
# ==============================================================================
|
||||
|
||||
# --- GPU Detection ---
|
||||
if [ -n "$(lspci | grep -i 'nvidia')" ]; then
|
||||
# --- Driver Selection ---
|
||||
# Turing (16xx, 20xx), Ampere (30xx), Ada (40xx), and newer recommend the open-source kernel modules
|
||||
if echo "$(lspci | grep -i 'nvidia')" | grep -q -E "RTX [2-9][0-9]|GTX 16"; then
|
||||
NVIDIA_DRIVER_PACKAGE="nvidia-open-dkms"
|
||||
else
|
||||
NVIDIA_DRIVER_PACKAGE="nvidia-dkms"
|
||||
fi
|
||||
NVIDIA="$(lspci | grep -i 'nvidia')"
|
||||
|
||||
if [ -n "$NVIDIA" ]; then
|
||||
# Check which kernel is installed and set appropriate headers package
|
||||
KERNEL_HEADERS="linux-headers" # Default
|
||||
if pacman -Q linux-zen &>/dev/null; then
|
||||
KERNEL_HEADERS="linux-zen-headers"
|
||||
elif pacman -Q linux-lts &>/dev/null; then
|
||||
KERNEL_HEADERS="linux-lts-headers"
|
||||
elif pacman -Q linux-hardened &>/dev/null; then
|
||||
KERNEL_HEADERS="linux-hardened-headers"
|
||||
KERNEL_HEADERS="$(pacman -Qqs '^linux(-zen|-lts|-hardened)?$' | head -1)-headers"
|
||||
|
||||
if echo "$NVIDIA" | grep -qE "RTX [2-9][0-9]|GTX 16"; then
|
||||
# Turing (16xx, 20xx), Ampere (30xx), Ada (40xx), and newer recommend the open-source kernel modules
|
||||
PACKAGES=(nvidia-open-dkms nvidia-utils lib32-nvidia-utils libva-nvidia-driver)
|
||||
elif echo "$NVIDIA" | grep -qE "GTX 9|GTX 10"; then
|
||||
# Pascal (10xx) and Maxwell (9xx) use legacy branch that can only be installed from AUR
|
||||
PACKAGES=(nvidia-580xx-dkms nvidia-580xx-utils lib32-nvidia-580xx-utils)
|
||||
fi
|
||||
# Bail if no supported GPU
|
||||
if [ -z "${PACKAGES+x}" ]; then
|
||||
echo "No compatible driver for your NVIDIA GPU. See: https://wiki.archlinux.org/title/NVIDIA"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# force package database refresh
|
||||
sudo pacman -Syu --noconfirm
|
||||
|
||||
# Install packages
|
||||
PACKAGES_TO_INSTALL=(
|
||||
"${KERNEL_HEADERS}"
|
||||
"${NVIDIA_DRIVER_PACKAGE}"
|
||||
"nvidia-utils"
|
||||
"lib32-nvidia-utils"
|
||||
"egl-wayland"
|
||||
"libva-nvidia-driver" # For VA-API hardware acceleration
|
||||
"qt5-wayland"
|
||||
"qt6-wayland"
|
||||
)
|
||||
|
||||
sudo pacman -S --needed --noconfirm "${PACKAGES_TO_INSTALL[@]}"
|
||||
pacman -S --needed --noconfirm "$KERNEL_HEADERS" "${PACKAGES[@]}"
|
||||
|
||||
# Configure modprobe for early KMS
|
||||
echo "options nvidia_drm modeset=1" | sudo tee /etc/modprobe.d/nvidia.conf >/dev/null
|
||||
sudo tee /etc/modprobe.d/nvidia.conf <<EOF >/dev/null
|
||||
options nvidia_drm modeset=1
|
||||
EOF
|
||||
|
||||
# Configure mkinitcpio for early loading
|
||||
MKINITCPIO_CONF="/etc/mkinitcpio.conf"
|
||||
sudo tee /etc/mkinitcpio.conf.d/nvidia.conf <<EOF >/dev/null
|
||||
MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
|
||||
EOF
|
||||
|
||||
# Define modules
|
||||
NVIDIA_MODULES="nvidia nvidia_modeset nvidia_uvm nvidia_drm"
|
||||
# Add NVIDIA environment variables
|
||||
cat >>$HOME/.config/hypr/envs.conf <<'EOF'
|
||||
|
||||
# Create backup
|
||||
sudo cp "$MKINITCPIO_CONF" "${MKINITCPIO_CONF}.backup"
|
||||
|
||||
# Remove any old nvidia modules to prevent duplicates
|
||||
sudo sed -i -E 's/ nvidia_drm//g; s/ nvidia_uvm//g; s/ nvidia_modeset//g; s/ nvidia//g;' "$MKINITCPIO_CONF"
|
||||
# Add the new modules at the start of the MODULES array
|
||||
sudo sed -i -E "s/^(MODULES=\\()/\\1${NVIDIA_MODULES} /" "$MKINITCPIO_CONF"
|
||||
# Clean up potential double spaces
|
||||
sudo sed -i -E 's/ +/ /g' "$MKINITCPIO_CONF"
|
||||
|
||||
sudo mkinitcpio -P
|
||||
|
||||
# Add NVIDIA environment variables to hyprland.conf
|
||||
HYPRLAND_CONF="$HOME/.config/hypr/hyprland.conf"
|
||||
if [ -f "$HYPRLAND_CONF" ]; then
|
||||
cat >>"$HYPRLAND_CONF" <<'EOF'
|
||||
|
||||
# NVIDIA environment variables
|
||||
# NVIDIA
|
||||
env = NVD_BACKEND,direct
|
||||
env = LIBVA_DRIVER_NAME,nvidia
|
||||
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -27,9 +27,12 @@ linux
|
||||
linux-firmware
|
||||
linux-headers
|
||||
macbook12-spi-driver-dkms
|
||||
nvidia-580xx-dkms
|
||||
nvidia-dkms
|
||||
nvidia-open-dkms
|
||||
nvidia-580xx-utils
|
||||
nvidia-utils
|
||||
lib32-nvidia-580xx-utils
|
||||
lib32-nvidia-utils
|
||||
pipewire
|
||||
pipewire-alsa
|
||||
|
||||
8
migrations/1766942230.sh
Normal file
8
migrations/1766942230.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
echo "Migrate legacy NVIDIA GPUs to nvidia-580xx driver (if needed)"
|
||||
|
||||
# Only migrate GTX 9xx or 10xx (Pascal/Maxwell)
|
||||
NVIDIA="$(lspci | grep -i 'nvidia')"
|
||||
if echo "$NVIDIA" | grep -qE "GTX 9|GTX 10"; then
|
||||
# Piping yes to override existing packages
|
||||
yes | sudo pacman -S nvidia-580xx-dkms nvidia-580xx-utils lib32-nvidia-580xx-utils
|
||||
fi
|
||||
Reference in New Issue
Block a user