mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
53 lines
2.0 KiB
Bash
53 lines
2.0 KiB
Bash
# ==============================================================================
|
|
# 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
|
|
#
|
|
# ==============================================================================
|
|
NVIDIA="$(lspci | grep -i 'nvidia')"
|
|
|
|
# --- GPU Detection ---
|
|
if [ -n "$NVIDIA" ]; then
|
|
# Check which kernel is installed and set appropriate headers package
|
|
KERNEL_HEADERS="$(pacman -Qqs '^linux(-zen|-lts|-hardened)?$' | head -1)-headers"
|
|
|
|
# Turing (16xx, 20xx), Ampere (30xx), Ada (40xx), and newer recommend the open-source kernel modules
|
|
# Pascal (10xx) and Maxwell (9xx) use legacy branch that can only be installed from AUR
|
|
if echo "$NVIDIA" | grep -qE "RTX [2-9][0-9]|GTX 16"; then
|
|
PACKAGES=(nvidia-open-dkms nvidia-utils lib32-nvidia-utils libva-nvidia-driver)
|
|
elif echo "$NVIDIA" | grep -qE "GTX 9|GTX 10"; then
|
|
PACKAGES=(nvidia-580xx-dkms nvidia-580xx-utils lib32-nvidia-580xx-utils)
|
|
else
|
|
echo "Your GPU is unsupported by NVIDIA or Arch."
|
|
echo "See: https://wiki.archlinux.org/title/NVIDIA"
|
|
exit 1
|
|
fi
|
|
|
|
pacman -S --needed --noconfirm "$KERNEL_HEADERS" "${PACKAGES[@]}"
|
|
|
|
# Configure modprobe for early KMS
|
|
sudo tee /etc/modprobe.d/nvidia.conf <<EOF >/dev/null
|
|
options nvidia_drm modeset=1
|
|
EOF
|
|
|
|
# Configure mkinitcpio for early loading
|
|
sudo tee /etc/mkinitcpio.conf.d/nvidia.conf <<EOF >/dev/null
|
|
MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
|
|
EOF
|
|
|
|
# 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
|
|
env = NVD_BACKEND,direct
|
|
env = LIBVA_DRIVER_NAME,nvidia
|
|
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
|
|
EOF
|
|
fi
|
|
fi
|