Skip to content

Commit

Permalink
profies/graphic_drivers: Replace PRIME profiles with checks in hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ventureoo committed Jul 12, 2024
1 parent 9d90cd4 commit db6ac70
Showing 1 changed file with 48 additions and 43 deletions.
91 changes: 48 additions & 43 deletions profiles/pci/graphic_drivers/profiles.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,30 @@ device_name_pattern = '(AD)\w+'
[nvidia-dkms]
desc = 'Closed source NVIDIA drivers for Linux (Latest)'
nonfree = true
class_ids = "0300 0380"
class_ids = "0300 0302 0380"
vendor_ids = "10de"
priority = 8
packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader'
conditional_packages = """
kernels="$(pacman -Qqs "^linux-cachyos")"
modules=""
packages=""
for kernel in $kernels; do
case "$kernel" in
*-headers|*-zfs);;
*-nvidia) modules+=" ${kernel}";;
*) modules+=" ${kernel}-nvidia";;
*-headers|*-zfs|*-dbg);;
*-nvidia) packages+=" ${kernel}";;
*) packages+=" ${kernel}-nvidia";;
esac
done
# Fallback if there are no kernels with pre-built modules
[ -z "$modules" ] && modules="nvidia-dkms"
[ -z "$packages" ] && packages="nvidia-dkms"
echo "$modules"
if lspci -d "*:*:030x" | grep -q -v NVIDIA; then
packages+=" nvidia-prime switcheroo-control"
fi
echo "$packages"
"""
post_install = """
cat <<EOF >/etc/mkinitcpio.conf.d/10-chwd.conf
Expand All @@ -53,37 +56,22 @@ MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
EOF
mkinitcpio -P
if lspci -d "*:*:030x" | grep -q -v NVIDIA; then
systemctl enable --now switcheroo-control
# Workaround to fix broken RTD3 on GNOME, which keeps taking up 1MB of VRAM
# without letting the dGPU fully sleep or keeping it running for long
# periods of time.
# See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2969
echo "export __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json" > /etc/profile.d/nvidia-rt3d-workaround.sh
fi
# Add libva-nvidia-driver to profile
echo "export LIBVA_DRIVER_NAME=nvidia" > /etc/profile.d/nvidia-vaapi.sh
"""
post_remove = """
rm -f /etc/mkinitcpio.conf.d/10-chwd.conf
rm -f /etc/profile.d/nvidia-vaapi.sh
mkinitcpio -P
"""
device_ids = '*'

[nvidia-dkms.prime]
desc = 'Closed source NVIDIA drivers for Linux (Latest)'
class_ids = "0302"
priority = 10
packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader nvidia-prime switcheroo-control'
post_install = """
cat <<EOF >/etc/mkinitcpio.conf.d/10-chwd.conf
# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT.
MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
EOF
mkinitcpio -P
systemctl enable switcheroo-control
# Workaround to fix broken RTD3 on GNOME, which keeps taking up 1MB of VRAM
# without letting the dGPU fully sleep or keeping it running for long
# periods of time.
# See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2969
echo "export __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json" > /etc/profile.d/nvidia-rt3d-workaround.sh
"""
post_remove = """
rm -f /etc/mkinitcpio.conf.d/10-chwd.conf
rm -f /etc/profile.d/nvidia-rt3d-workaround.sh
mkinitcpio -P
"""
Expand All @@ -93,26 +81,43 @@ device_ids = '*'
desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)'
priority = 8
nonfree = true
class_ids = "0300 0380"
class_ids = "0300 0302 0380"
vendor_ids = "10de"
packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver'
device_name_pattern = '(GK)\w+'
post_install = """
cat <<EOF >/etc/mkinitcpio.conf.d/10-chwd.conf
# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT.
MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
EOF
mkinitcpio -P
if lspci -d "*:*:030x" | grep -q -v NVIDIA; then
systemctl enable --now switcheroo-control
# Workaround to fix broken RTD3 on GNOME, which keeps taking up 1MB of VRAM
# without letting the dGPU fully sleep or keeping it running for long
# periods of time.
# See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2969
echo "export __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json" > /etc/profile.d/nvidia-rt3d-workaround.sh
fi
# Add libva-nvidia-driver to profile
echo "export LIBVA_DRIVER_NAME=nvidia" > /etc/profile.d/nvidia-vaapi.sh
"""
conditional_packages = """
packages=""
if lspci -d "*:*:030x" | grep -q -v NVIDIA; then
packages+=" nvidia-prime switcheroo-control"
fi
echo "$packages"
"""
post_remove = """
rm -f /etc/mkinitcpio.conf.d/10-chwd.conf
rm -f /etc/profile.d/nvidia-vaapi.sh
"""

[nvidia-dkms-470xx.prime]
desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)'
priority = 9
class_ids = "0302"
packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver switcheroo-control nvidia-prime'
device_name_pattern = '(GK)\w+'
post_install = """
systemctl enable switcheroo-control
rm -f /etc/profile.d/nvidia-rt3d-workaround.sh
mkinitcpio -P
"""

[nvidia-dkms-390xx]
Expand Down

0 comments on commit db6ac70

Please sign in to comment.