Skip to content

Instantly share code, notes, and snippets.

@guihkx
Created June 5, 2024 07:21
Show Gist options
  • Save guihkx/e9b36f4d627d7a360e1a4f6689c664ff to your computer and use it in GitHub Desktop.
Save guihkx/e9b36f4d627d7a360e1a4f6689c664ff to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# NOTE: After running this script, you must remove every ".ld.so" directory in ~/.var/app/<id>, so that the ld cache file can be regenerated, and the new driver libs found:
# find ~/.var/app/ -maxdepth 2 -type d -name .ld.so -exec rm -Ir {} \;
# https://docs.flatpak.org/en/latest/extension.html#unmaintained-flatpak-extensions
# https://blog.tingping.se/2018/08/26/flatpak-host-extensions.html
# system-wide
root64='/var/lib/flatpak/extension/org.freedesktop.Platform.GL.host'
root32='/var/lib/flatpak/extension/org.freedesktop.Platform.GL32.host'
arch='x86_64'
branch='1.4'
mkdir -p "${root64}/${arch}/${branch}"
mkdir -p "${root64}/${arch}/${branch}/egl/egl_external_platform.d"
mkdir -p "${root64}/${arch}/${branch}/glvnd/egl_vendor.d"
mkdir -p "${root64}/${arch}/${branch}/lib/nvidia/wine"
mkdir -p "${root64}/${arch}/${branch}/OpenCL/vendors"
mkdir -p "${root64}/${arch}/${branch}/share/nvidia"
mkdir -p "${root64}/${arch}/${branch}/vulkan/icd.d"
mkdir -p "${root64}/${arch}/${branch}/vulkan/implicit_layer.d"
# TOOD: check if we aren't missing crucial libs from nvidia-470xx-utils
ln /usr/share/egl/egl_external_platform.d/10_nvidia_wayland.json "${root64}/${arch}/${branch}/egl/egl_external_platform.d"
ln /usr/share/glvnd/egl_vendor.d/10_nvidia.json "${root64}/${arch}/${branch}/glvnd/egl_vendor.d"
ln /usr/lib/libcuda.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libEGL_nvidia.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libGLESv* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libGLX_nvidia.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/nvidia/wine/_nvngx.dll "${root64}/${arch}/${branch}/lib/nvidia/wine"
ln /usr/lib/nvidia/wine/nvngx.dll "${root64}/${arch}/${branch}/lib/nvidia/wine"
ln /usr/lib/nvidia/xorg/libglxserver_nvidia.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvcuvid.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-allocator.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-cbl.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-cfg.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-egl-wayland.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-eglcore.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-encode.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-fbc.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-glcore.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-glsi.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-glvkspirv.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-ifr.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-ml.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-opticalflow.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-ptxjitcompiler.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-rtcore.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-tls.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvidia-vulkan-producer.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/libnvoptix.so* "${root64}/${arch}/${branch}/lib"
ln /usr/lib/vdpau/libvdpau_nvidia.so* "${root64}/${arch}/${branch}/lib"
ln /usr/share/nvidia/nvidia-application-profiles-* "${root64}/${arch}/${branch}/share/nvidia"
ln /usr/share/vulkan/icd.d/nvidia_icd.json "${root64}/${arch}/${branch}/vulkan/icd.d"
ln /usr/share/vulkan/implicit_layer.d/nvidia_layers.json "${root64}/${arch}/${branch}/vulkan/implicit_layer.d"
# 32-bit
mkdir -p "${root32}/${arch}/${branch}"
mkdir -p "${root32}/${arch}/${branch}/egl/egl_external_platform.d"
mkdir -p "${root32}/${arch}/${branch}/glvnd/egl_vendor.d"
mkdir -p "${root32}/${arch}/${branch}/lib"
mkdir -p "${root32}/${arch}/${branch}/OpenCL/vendors"
mkdir -p "${root32}/${arch}/${branch}/share/nvidia"
mkdir -p "${root32}/${arch}/${branch}/vulkan/icd.d"
mkdir -p "${root32}/${arch}/${branch}/vulkan/implicit_layer.d"
# TODO: check if we aren't missing crucial libs from lib32-nvidia-470xx-utils
ln /usr/share/egl/egl_external_platform.d/10_nvidia_wayland.json "${root32}/${arch}/${branch}/egl/egl_external_platform.d"
ln /usr/share/glvnd/egl_vendor.d/10_nvidia.json "${root32}/${arch}/${branch}/glvnd/egl_vendor.d"
ln /usr/lib32/libcuda.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libEGL_nvidia.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libGLESv* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libGLX_nvidia.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvcuvid.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-allocator.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-eglcore.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-encode.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-fbc.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-glcore.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-glsi.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-glvkspirv.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-ifr.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-ml.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-opticalflow.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-ptxjitcompiler.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/libnvidia-tls.so* "${root32}/${arch}/${branch}/lib"
ln /usr/lib32/vdpau/libvdpau_nvidia.so* "${root32}/${arch}/${branch}/lib"
ln /usr/share/nvidia/nvidia-application-profiles-* "${root32}/${arch}/${branch}/share/nvidia"
ln /usr/share/vulkan/icd.d/nvidia_icd.json "${root32}/${arch}/${branch}/vulkan/icd.d"
ln /usr/share/vulkan/implicit_layer.d/nvidia_layers.json "${root32}/${arch}/${branch}/vulkan/implicit_layer.d"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment