Nvidia Problems with egl/simpledrm

Hi! To preface: I am new to nixos, so maybe I am just dumb.

Since Installing with my config on my desktop I am facing nvidia issues, particularly with egl (I think).

For example I can not open my anki it throws libEGL warning: egl: failed to create dri2 screen and segfaults. This can be fixed by using the vulkan graphics api for anki but well this does not really solve the root of the error.
I may be wrong but it seems these errors only happen for xwayland programs (not sure on that one).

eglinfo also gives me this error and more:

$ eglinfo | grep '(warning|error)'
MESA-LOADER: failed to open simpledrm: /run/opengl-driver/lib/dri/simpledrm_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)
MESA-LOADER: failed to open simpledrm: /run/opengl-driver/lib/dri/simpledrm_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)
libEGL warning: egl: failed to create dri2 screen

Here are some logs/findings:

The nvidia seems to load just fine:

$ dmesg | grep nvidia
[    0.000000] Command line: initrd=\EFI\nixos\54axbzlkcj9brdav7nj1kjgmmv52jlzb-initrd-linux-6.6.32-initrd.efi init=/nix/store/1nqxps3w3fq4xk8ndd3f38n96pxqxjs3-nixos-system-nixos-desktop-24.05.20240606.9b5328b/init nvidia.NVreg_PreserveVideoMemoryAllocations=1 NVreg_UsePageAttributeTable=1 loglevel=4 nvidia-drm.modeset=1 nvidia.NVreg_PreserveVideoMemoryAllocations=1 vt.default_red=0x23,0xb1,0xbf,0x8f,0x8f,0x8f,0x93,0xdd,0x9d,0xb1,0xbf,0x8f,0x8f,0x8f,0x93,0xea vt.default_grn=0x23,0x88,0x83,0x92,0x92,0x92,0x91,0xe4,0x9f,0x88,0x83,0x92,0x92,0x92,0x91,0xef vt.default_blu=0x24,0x6b,0x5a,0x87,0x86,0x88,0x85,0xdc,0x92,0x6b,0x5a,0x87,0x86,0x88,0x85,0xe9
[    0.078344] Kernel command line: initrd=\EFI\nixos\54axbzlkcj9brdav7nj1kjgmmv52jlzb-initrd-linux-6.6.32-initrd.efi init=/nix/store/1nqxps3w3fq4xk8ndd3f38n96pxqxjs3-nixos-system-nixos-desktop-24.05.20240606.9b5328b/init nvidia.NVreg_PreserveVideoMemoryAllocations=1 NVreg_UsePageAttributeTable=1 loglevel=4 nvidia-drm.modeset=1 nvidia.NVreg_PreserveVideoMemoryAllocations=1 vt.default_red=0x23,0xb1,0xbf,0x8f,0x8f,0x8f,0x93,0xdd,0x9d,0xb1,0xbf,0x8f,0x8f,0x8f,0x93,0xea vt.default_grn=0x23,0x88,0x83,0x92,0x92,0x92,0x91,0xe4,0x9f,0x88,0x83,0x92,0x92,0x92,0x91,0xef vt.default_blu=0x24,0x6b,0x5a,0x87,0x86,0x88,0x85,0xdc,0x92,0x6b,0x5a,0x87,0x86,0x88,0x85,0xe9
[    6.987737] nvidia: loading out-of-tree module taints kernel.
[    6.987746] nvidia: module license 'NVIDIA' taints kernel.
[    6.987752] nvidia: module license taints kernel.
[    7.579863] nvidia-nvlink: Nvlink Core is being initialized, major device number 238
[    7.581145] nvidia 0000:08:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=io+mem
[    7.862337] nvidia_uvm: module uses symbols nvUvmInterfaceDisableAccessCntr from proprietary module nvidia, inheriting taint.
[    8.248338] nvidia-uvm: Loaded the UVM driver, major device number 236.
[    8.271107] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  550.78  Sun Apr 14 06:23:31 UTC 2024
[    8.278202] [drm] [nvidia-drm] [GPU ID 0x00000800] Loading driver
[   10.011365] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:08:00.0 on minor 1

I also checked for “simpledrm”, while I do not know what that is it does appear in the dmesg:

$ dmesg | grep simple
[    0.450492] [drm] Initialized simpledrm 1.0.0 20200625 for simple-framebuffer.0 on minor 0
[    0.450917] simple-framebuffer simple-framebuffer.0: [drm] fb0: simpledrmdrmfb frame buffer device

This is a segfault example of anki as shown in journalctl (if you need the whole coredump stacktrace, just ask):

nixos kernel: anki[6804]: segfault at 178 ip 00007fbec08fc630 sp 00007ffc78b7b3f0 error 4 in libnvidia-glcore.so.550.78[7fbec0000000+c00000] likely on CPU 8 (core 0, socket 0)
                                              #0  0x00007f98080fc630 n/a (libnvidia-glcore.so.550.78 + 0xcfc630)
                                              #1  0x00007f980810e637 n/a (libnvidia-glcore.so.550.78 + 0xd0e637)
                                              #2  0x00007f9808149699 n/a (libnvidia-glcore.so.550.78 + 0xd49699)
                                              #3  0x00007f9809610ce0 n/a (libGLX_nvidia.so.0 + 0x9cce0)
                                              #2  0x00007f9807df351c n/a (libnvidia-glcore.so.550.78 + 0x9f351c)
                                              #3  0x00007f980823d1f1 n/a (libnvidia-glcore.so.550.78 + 0xe3d1f1)
                                              #4  0x00007f9807df59d4 n/a (libnvidia-glcore.so.550.78 + 0x9f59d4)
                                              #2  0x00007f9807df351c n/a (libnvidia-glcore.so.550.78 + 0x9f351c)
                                              #3  0x00007f9808308394 n/a (libnvidia-glcore.so.550.78 + 0xf08394)
                                              #4  0x00007f98082f5466 n/a (libnvidia-glcore.so.550.78 + 0xef5466)
                                              #5  0x00007f9807df59d4 n/a (libnvidia-glcore.so.550.78 + 0x9f59d4)
                                              #2  0x00007f9807df34bc n/a (libnvidia-glcore.so.550.78 + 0x9f34bc)
                                              #3  0x00007f9808226d65 n/a (libnvidia-glcore.so.550.78 + 0xe26d65)
                                              #4  0x00007f9807df59d4 n/a (libnvidia-glcore.so.550.78 + 0x9f59d4)
                                              #2  0x00007f9807df351c n/a (libnvidia-glcore.so.550.78 + 0x9f351c)
                                              #3  0x00007f980822c3b1 n/a (libnvidia-glcore.so.550.78 + 0xe2c3b1)
                                              #4  0x00007f9807df59d4 n/a (libnvidia-glcore.so.550.78 + 0x9f59d4)
                                              #2  0x00007f9807df351c n/a (libnvidia-glcore.so.550.78 + 0x9f351c)
                                              #3  0x00007f9808210bad n/a (libnvidia-glcore.so.550.78 + 0xe10bad)
                                              #4  0x00007f9807df59d4 n/a (libnvidia-glcore.so.550.78 + 0x9f59d4)
                                              #2  0x00007f9807df34bc n/a (libnvidia-glcore.so.550.78 + 0x9f34bc)
                                              #3  0x00007f98080f98ab n/a (libnvidia-glcore.so.550.78 + 0xcf98ab)
                                              #4  0x00007f9807df59d4 n/a (libnvidia-glcore.so.550.78 + 0x9f59d4)

My nvidia-specific config

So I tried a lot so there may be some redundant junk in the config.
In general I followed the offical nvidia docs and the hyprland docs for nvidia. I also took some stuff from other configs.

{ pkgs, config, ... }: {
  environment = {
    variables = {
      NIXOS_OZONE_WL = "1";
      GBM_BACKEND = "nvidia-drm";
      GBM_BACKENDS_PATH = "/run/opengl-driver/lib/gbm";
      __GL_GSYNC_ALLOWED = "0";
      __GL_VRR_ALLOWED = "0";
      __GL_THREADED_OPTIMIZATION = "1";
      __GL_SHADER_CACHE = "1";
      DISABLE_QT5_COMPAT = "0";
      ANKI_WAYLAND = "1";
      DIRENV_LOG_FORMAT = "";
      WLR_DRM_NO_ATOMIC = "1";
      __GLX_VENDOR_LIBRARY_NAME = "nvidia";
      LIBVA_DRIVER_NAME = "nvidia";
      QT_QPA_PLATFORM = "wayland";
      QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
      QT_QPA_PLATFORMTHEME = "qt5ct";
      MOZ_ENABLE_WAYLAND = "1";
      WLR_BACKEND = "vulkan";
      WLR_NO_HARDWARE_CURSORS = "1";
      XDG_SESSION_TYPE = "wayland";
      CLUTTER_BACKEND = "wayland";
      WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0";
      VK_DRIVER_FILES = "/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json";
    };
  };

  services.xserver.videoDrivers = [ "nvidia" ];
  virtualisation.docker.enableNvidia = true;
  boot.kernelParams = [
    "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
    "NVreg_UsePageAttributeTable=1"
  ];

  hardware = {
    nvidia = {
      open = false;
      powerManagement.enable = true;
      modesetting.enable = true;
      nvidiaSettings = false;
      package = config.boot.kernelPackages.nvidiaPackages.stable;
    };
    opengl = {
      enable = true;
      driSupport = true;
      driSupport32Bit = true;
      extraPackages = with pkgs; [
        vaapiVdpau
        libvdpau-va-gl
        nvidia-vaapi-driver
      ];
    };
  };

  environment.systemPackages = with pkgs; [
    glxinfo
    clinfo
    nvtopPackages.nvidia
    vulkan-loader
    vulkan-tools
  ];
}

Platform:

  • DM/WM: tuigreet/hyprland + wayland
  • GPU: RTX 2080
  • NixOS 24.05

simpledrm is just a very simple graphics driver for before the real graphics driver is loaded; i.e. it’s supposed to stop being relevant very early during boot. If you’re still using simpledrm by the time you reach the desktop, I’m pretty sure something’s wrong.

Ok Interesting, maybe this indicates some display manager misconfiguration? But I do not know because it seems the nvidia-drm driver loaded just fine…

For anyone interested this is my tuigreet config:

{ pkgs
, inputs
, ...
}:
let
  tuigreet = "${pkgs.greetd.tuigreet}/bin/tuigreet";
  theme = "border=magenta;text=cyan;prompt=green;time=red;action=blue;button=yellow;container=black;input=red";
in
{
  services.greetd = {
    enable = true;
    settings = {
      default_session = {
        command = "${tuigreet} -tr --remember-session --theme ${theme} --asterisks --cmd hyprland";
        user = "greeter";
      };
    };
  };

  systemd.services.greetd.serviceConfig = {
    Type = "idle";
    StandardInput = "tty";
    StandardOutput = "tty";
    StandardError = "journal";
    TTYReset = true;
    TTYVHangup = true;
    TTYVTDisallocate = true;
  };
}

Just a little update: I tried using gdm as I heard it can handle hyprland quite well, but it does not fix the problem. So it is probably not the dm causing the problems.

Edit: I am switching sides, amd it is. This is not solved per se, but soon it won’t be my problem anymore.