In this article I will summarize my steps to solve nvidia issues on my nixos setup.
After Switching from Arch Linux to NixOS I focused my attention at fixing the hardware issues I had with Arch Linux. I have managed to solve the laptop-specific issues like non functional speakers and yet… I had trouble getting Nvidia to work.
A disclaimer - I am not that versed nor interested in hardware, so the nvidia and intel configurations went right over my head. Everyone says that working with nvidia on linux is a pain in the ass. Not only that I also chose to use wayland, which has it’s own problems with linux.
First attempts
I first began by looking at the NixOS hardware git repository, which contains pre-configured hardware configurations for a lot of systems. Sadly mine wasn’t on there, with the closest being Lenovo Yoga 7 14ARH7.
The next attempt came in copying alyraffauf’s NixOS config of my laptop, which can be found here. I appreciated the modularity and setup, however not everything worked as I wanted (but it did fix my audio issues) namely launching chromium I got an error MESA-LOADER: failed to open nvidia-drm
Solving the issues with Google Gemini
After going through the nix forums, github issues, etc. I have had enough. My knowledge is not that deep to understand the granular differences between Nvidia package versions - propriatery vs open, stable vs beta, drivers such as nvidia-vaapi-driver, etc.
Having access to Google Gemini’s Deep Research with 2.5 Pro I tried to research the ways to refactor all the files I had copied from alyraffauf’s setup and asked it to help me solve the MESA-LOADER issue.
Remarkably it:
- found the model and component versions of my laptop
- a way to determine PCI Bus IDs (Crucial for PRIME)
- reviewed the provided code and suggested modifications
- explained the options, what they meant, what values to set and why
- printed the whole configuration file as one
- showed all the 132 referenced websites
I then asked it to split it into multiple modules to separate the concerns. I chose four in total: user software, user hardware, laptop graphics hardware, laptop audio hardware
Fixing nvidia-drm driver has no member named ‘date’
Trying to nixos-rebuild the modules produced a very cryptic error
error: builder for '/nix/store/jp80rqnlfvf05ps3g7rnqyp3zaic3fck-nvidia-x11-565.77-6.14.drv' failed with exit code 2;
last 25 log lines:
> CC [M] nvidia-drm/nvidia-drm-modeset.o
> CC [M] nvidia-drm/nvidia-drm-fence.o
> CC [M] nvidia-drm/nvidia-drm-helper.o
> CC [M] nvidia-drm/nv-kthread-q.o
> CC [M] nvidia-drm/nv-pci-table.o
> CC [M] nvidia-drm/nvidia-drm-gem-nvkms-memory.o
> CC [M] nvidia-drm/nvidia-drm-gem-user-memory.o
> CC [M] nvidia-drm/nvidia-drm-gem-dma-buf.o
> nvidia-drm/nvidia-drm-drv.c:1907:6: error: 'struct drm_driver' has no member named 'date'
> 1907 | .date = "20160202",
> | ^~~~
> nvidia-drm/nvidia-drm-drv.c:1907:31: warning: initialization of 'unsigned int' from 'char *' makes integer from pointer without a cast []
> 1907 | .date = "20160202",
> | ^~~~~~~~~~
> nvidia-drm/nvidia-drm-drv.c:1907:31: note: (near initialization for 'nv_drm_driver.driver_features')
> nvidia-drm/nvidia-drm-drv.c:1907:31: error: initializer element is not computable at load time
> nvidia-drm/nvidia-drm-drv.c:1907:31: note: (near initialization for 'nv_drm_driver.driver_features')
> make[4]: *** [/nix/store/1wjcww3hgrf7ymfmss9zw2g13b03rg2k-linux-6.14-dev/lib/modules/6.14.0/source/scripts/Makefile.build:207: nvidia-drm/nvidia-drm-drv.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [/nix/store/1wjcww3hgrf7ymfmss9zw2g13b03rg2k-linux-6.14-dev/lib/modules/6.14.0/source/Makefile:1994: .] Error 2
> make[2]: *** [/nix/store/1wjcww3hgrf7ymfmss9zw2g13b03rg2k-linux-6.14-dev/lib/modules/6.14.0/source/Makefile:251: __sub-make] Error 2
> make[2]: Leaving directory '/build/NVIDIA-Linux-x86_64-565.77/kernel'
> make[1]: *** [Makefile:251: __sub-make] Error 2
> make[1]: Leaving directory '/nix/store/1wjcww3hgrf7ymfmss9zw2g13b03rg2k-linux-6.14-dev/lib/modules/6.14.0/source'
> make: *** [Makefile:115: modules] Error 2
For full logs, run 'nix log /nix/store/jp80rqnlfvf05ps3g7rnqyp3zaic3fck-nvidia-x11-565.77-6.14.drv'.
error: 1 dependencies of derivation '/nix/store/f4kgcf10rqmi0gp5hzlsdrhzfz3p4v3c-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/slg73j2qvlahk8dqggkhdz6xl14j1qa6-firmware.drv' failed to build
error: 1 dependencies of derivation '/nix/store/awv16bbx3nz7xylfwvayyz7y1l72cw48-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/svsx31a7yslb59fbrvzw08vwsbqdm46y-nixos-system-yoga-24.11.20250325.d02d88f.drv' failed to buildAfter gemini researched a bit, it suggested some options, first of which was to change
boot.kernelPackages = pkgs.linuxPackages_latest; to a lower version such as linuxPackages_6_12. Another alternative was to change hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; to a different version.
Lowering the linux version to 6.12 fixed the issue for me.
Fixing libva error: /run/opengl-driver/lib/dri/nvidia_drv_video.so init failed
From one error to another. Launching chromium now produced a different error
libva error: /run/opengl-driver/lib/dri/nvidia_drv_video.so init failed
Gemini told me that the env variable $LIBVA_DRIVER_NAME should not be set, but after printing the variable it was indeed set to “nvidia”. After searching a little I have found that in my hyprland config I have included the line env = LIBVA_DRIVER_NAME,nvidia which I had to remove.
Verifying that everything works
As a last thing I asked Gemini how to check that everything works as expected. The response was as follows:
Here’s a breakdown of how you can verify that the key parts of your setup are working correctly and how to generally check for errors:
1. Verify Your Current Setup:
- Kernel Version: Confirm you are indeed running the kernel you switched to.
uname -r(This should output a version starting with 6.12.x)
- Nvidia Driver and GPU Status: Check if the Nvidia driver is loaded and recognizes your GPU.
nvidia-smi(This should show details about your Nvidia GPU, the driver version (likely 565.77), and ideally low power usage/no running processes if nothing demanding is running)
- PRIME Render Offload: Verify that OpenGL rendering defaults to the Intel GPU but can be offloaded to Nvidia.
# Check default renderer (should be Intel)
glxinfo -B | grep "OpenGL renderer string"
# Check offloaded renderer (should be Nvidia)
nvidia-offload glxinfo -B | grep "OpenGL renderer string"(You might need to install mesa-utils via environment.systemPackages if glxinfo isn’t found)
- Video Acceleration (VA-API): Check if both Intel and Nvidia VA-API drivers are recognized correctly.
# Check default VA-API (should show Intel iHD driver)
vainfo
# Check offloaded VA-API (should show Nvidia driver)
nvidia-offload vainfo(This tests if the system can correctly select the VA-API driver based on whether nvidia-offload is used. The libva error:... init failed should be gone now when running applications like Chromium normally. You need libva-utils installed for vainfo)
- Speaker Fix: Play some audio and confirm the bass speakers are working. You can also check the status of the systemd service:
systemctl status yoga-speaker-fix.service
journalctl -u yoga-speaker-fix.service(Look for successful execution messages in the journal)
- Power Profiles Daemon: Check if the power management service is active.
systemctl status power-profiles-daemon.service(This should show “active (running)“. The UPower errors in Chromium might disappear if this service is running correctly, as it’s the modern replacement)
- Hyprland Environment Variables: (Optional) You can check if the environment variables set in your NixOS config are active within your Hyprland session:
echo $GBM_BACKEND
echo $NIXOS_OZONE_WL(These should reflect the values set in graphics.nix)
Conclusion
In the end I have managed to successfully configure Nvidia (or at least I hope I did). The good thing is that this being NixOS I can easily reproduce it next time. But to tell the truth I have no idea what I just configured and I will just hope that it works in the future. Happy hacking.