I've spend way too long to get the NVIDIA-driver to work, as well as taming the overheating problem which has haunted my ideapad forever. I hope this config can save somebody else lots of time (please comment!), as I experienced weird catch22 scenarios because of the dual-video driver.
note: if you laptop still overheats, lower the
CPU_SCALING_MAX_FREQ
variables.
You can now run apps on the NVIDIA GPU by creating this nvidia-run
shellscript-wrapper:
#!/bin/sh
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec "$@"
$ nix-shell -p glxinfo --run glxinfo| grep 'OpenGL vendor'
OpenGL vendor string: Intel
$ ./nvidia-run nix-shell -p glxinfo --run glxinfo| grep 'OpenGL vendor'
OpenGL vendor string: NVIDIA Corporation