Newbie Question: Hyprland on Nvidia - wlr_backend_autocreate() failed

When I try to start Hyprland, the program crashes and spits out:

[CRITICAL] m_sWLRBackend was NULL!
[CRITICAL] what(): wlr_backend_autocreate()!

Searching, I found this Hyprland issue, stating it is related to NVIDIA.

My system has the following GPU:

Intel HD Graphics 630
NVIDIA GeForce 940MX

I found the page “How to get Hyprland to possibly work on Nvidia”, so I have tried with a wrapper.

I have also looked at this post, where another person struggled with NVIDIA.

I can not find my card under NVIDIA Linux Open GPU Kernel Module Source. Does that mean I can not use Hyprland at all?

1 Like

By the way, here is my configuration.nix:
https://paste.simplylinux.ch/view/00a9ea66

The Hyperland Wiki you are links to Arch, where you are asked to install nvidia-dkms and add it to initramfs and the kernel parameters. Is that needed on NixOS as well? If yes, can this be done directly from the config? How? I do not even find nvidia-dkms in the package database. UPDATE: nvidia-dkms is closed source, and hence not in the package db, I assume. More info on nvidia vs nvidia-dkms.

Here is the content of my wrappedhl:

#!/bin/sh

cd ~
export _JAVA_AWT_WM_NONREPARENTING=1
export XCURSOR_SIZE=24
export WLR_RENDERER=vulkan
export __GL_GSYNC_ALLOWED=0
export __GL_VRR_ALLOWED=0

When I check the Wayland requirements it looks like my NVIDIA GPU is supported (NVIDIA GeForce 940MX). And this should be the latest driver. So, I guess it is not my card that is too old.

Disclaimer:
I discovered NixOS quite recently and decided to give it a go, as I loved the concept of easily setting up the same system on several laptops, and rolling back in case something gets messed up. However, as I am brand new to NixOS and not even a skilled Linux user this is far from trivial to me. I might be in too deep water. Still, I would really love to get Hyprland going on NixOS.

I am typing to you from Hyprland on Nvidia right now. I use Hyprland from the upstream flake (not sure if that makes a difference). I also use the proprietary Nvidia driver for now, sounds like you might be going with the open one. Can’t speak to that, but at least with my current setup, it is possible:

Typically I launch Hyprland from the intel GPU just to save on power, but I can launch it with the Nvidia card directly by specifying the WLR_DRM_DEVICES variable, pointing to the dri device representing my nvidia card. I almost never do this though, and instead I mostly rely on offload if I ever need the more powerful card.

2 Likes

Thank you, @nrdxp! I appreciate your input.

Great to know that it works with Nvidia. I looked at your config, updated my configuration.nix, and tried again.

Now, if I run Hyprland it finally starts (yay), using the Intel GPU. I assume it is the same as running the command:
WLR_DRM_DEVICES=/dev/dri/card0 Hyprland

To use NVIDIA, I can, as you suggested, run:
WLR_DRM_DEVICES=/dev/dri/card1 Hyprland

If I do this, Hyprland still crashes after a few seconds, like before:

[CRITICAL] m_sWLRBackend was NULL!
[CRITICAL] what(): wlr_backend_autocreate()!

For video drivers, I have tried both:
services.xserver.videoDrivers = ["nvidia"];
and
services.xserver.videoDrivers = ["nvidia-dkms"];
(I read somewhere that nvidia-dkms was better to use, at it was kernel independent.)

I also copied the following lines from your config:

  hardware.opengl = {
    extraPackages = with pkgs; [nvidia-vaapi-driver intel-media-driver];
    extraPackages32 = with pkgs.pkgsi686Linux; [nvidia-vaapi-driver intel-media-driver];
  };

I saw that you had a nvrun command as well, that works as a wrapper. So, I added this as well, and tried running nvrun Hyprland. Still, the same error.

I am not sure if it is related, but when I run sudo gamescope it crashes, outputting:
AbortedulkanTexture*): Assertion 'drmFormatDesc != nullptr' failed.(...

I must be doing something wrong, but I am struggling to see where I am messing up.

It may be important to point out that, on my laptop at least, my Nvidia card is wired directly to the HDMI port, so if I try to launch Hyprland directly on it with the aforementioned WLR_DRM_DEVICES I have to have a monitor pluggined into the HDMI port to actually see anything.

The nvrun command is just a simple wrapper to offload graphics for a specific process onto the Nvidia card when desired. The way that works at a high level is that the Nvidia card does the rendering for a specific process while the rest of the display is still managed by the Intel chip.

I’m not sure using nvrun to launch Hyprland itself is a good idea, or if it will even work. That is mostly used to offload specific programs you want to run on the Nvidia card from an already running compositor, say a graphics heavy game or Steam.

If you really want to use only the Nvidia card, you can setup the older Prime Sync, which essentially routes all graphics through the Nvidia card but presents it through the Intel display buffer so it will actually show on the laptop screen. This used to be the only option before offload was a thing, and I used it years ago, but I wasn’t even using NixOS back then. Looks like there are instructions in the wiki though if that’s the route you want to take, just keep in mind that it will drain your laptop battery a lot faster.

1 Like

Thank you, once again, @nrdxp.

I changed my config so that Optimus PRIME Option B: Sync Mode is chosen. Then, I started up Hyprland and ran glxinfo | egrep "OpenGL" to check what GPU was active (I got some help from this page). The result I got was:

OpenGL vendor string: Intel
OpenGL renderer string: Mesa Interl(R) HD Graphics 630 (KBL GT2)

You wrote that:

Prime Sync … routes all graphics through the Nvidia card but presents it through the Intel display buffer so it will actually show on the laptop screen.

Still, I assumed I should have seen NVIDIA in the above result, if that card was active. So, to me it seems like I have not managed to activate the NVIDIA GPU.

When I start nvidia-settings, no card shows up in the menu.

As well, running nvidia-smi, I get:
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

lspci -vnnn outputs:

Kernel driver in use: nouveu
Kernel modules: nvidiafb, nouveau

Something I find strange, that I though I was using the proprietary NVIDIA driver, and not the open source nouveau driver. How can I specify to a proprietary NVIDIA driver, instead of nouveau?

For a Linux newbie this is not super easy. The NixOS learning curve is steep indeed.


UPDATE: OK, I am a beginner. It shows as I did not think of having to do a reboot for the effects taking place. I suddenly realised that it might be needed. After I rebooted my system, I now get the following values for the NVIDIA GPU:

Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

Running nvidia-smi my card is listed, and when I open nvidia-settings I also see my card.

Here is my latest configuration.nix.

So, it looks like my problem is solved. Thanks a lot for great help, @nrdxp. I will set your first answer as the solution, even though the second one also contained great info.

1 Like