Using Nvidia Optimus on Void Linux

What is optimus technology?

According to gentoo wiki

NVIDIA Optimus is a proprietary technology that seamlessly switches between two GPUs. It is typically used on systems that have an integrated Intel GPU and a discrete NVIDIA GPU. The main benefit of using NVIDIA Optimus is to extend battery life by providing maximum GPU performance only when needed.

There is a great wiki about using bumblebee(not transformer) on void linux but bumblebee’s project last commit was in 2013 and it doesn’t support vulkan, so no luck for linux gamers. A better way is to use a utility like nvidia-prime which is available for ubuntu or optimus-manager which is available for arch-based distros(available in AUR). Sadly, these projects require systemd as a init system. There is only one project which uses shell script and partly depends on systemd but is pretty hackable - nvidia-xrun.

Problem on void

libglvnd is broken in void repos which makes it hard to have multiple drivers from different vendors to coexist on the same filesystem. This results in having either openGL libraries from mesa or nvidia.

The Hack

Install nvidia openGL libraries in /opt directory and point nvidia-xrun to use them. This is just a workaround of libglvnd.

First of all install these packages:

Create a file /etc/modprobe.d/nvidia.conf for blacklisting nvidia kernel modules so that they won’t be loaded at boot. Add the following text:

blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
blacklist nvidia-uv
blacklist nouveau

Next create some directories

$ sudo mkdir /opt/nvidia
$ sudo mkdir -p /opt/nvidia/fakeroot/usr/lib
$ sudo mkdir -p /opt/nvidia/fakeroot/usr/lib32
$ sudo mkdir /etc/X11/nvidia

Now we have to create a fakeroot directory with nvidia openGL libraries

$ sudo ln -s /opt/nvidia/fakeroot/usr/lib /opt/nvidia/fakeroot/lib
$ sudo ln -s /opt/nvidia/fakeroot/usr/lib32 /opt/nvidia/fakeroot/lib32
$ sudo chmod 755 -R /opt/nvidia/fakeroot
$ xbps-install --rootdir /opt/nvidia/fakeroot --repository --repository --repository --repository --yes --sync nvidia nvidia-libs nvidia-libs-32bit

Next clone my repo and move the scripts to respective location

$ git clone
$ cd optimus-hack/
$ sudo cp -r xorg.conf xorg.conf.d /etc/X11/nvidia/
$ sudo cp /opt/nvidia/

There is also which ensures that GPU is off. Run this as root at boot.

Also add these lines in your ~/.xinitrc.

# load additional configs
if [ "$2" = "nvidia" ]; then

if [ -d "$XINIT_D" ]; then
    for f in "$XINIT_D/?*.sh" ; do
        [ -x "$f" ] && . "$f"
    unset f
unset XINIT_D

# additional nvidia specific settings
if [ "$2" = "nvidia" ]; then    
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto

Now close your X session and run /opt/nvidia/

And boom! Your X session is now running on nvidia opengl libraries.


If steam complains about missing libGL. Run steam using this command



I don’t recommend using this method but this is the only thing that worked for me.

See this article for more details - here