Logseq Electron App not working with Nvidia

I installed the NixOS install of Logseq via my configuration.nix file and my install uses the official Nvidia drivers. But when I open Logseq I get the following error:

[12352:0629/172646.336673:ERROR:gbm_wrapper.cc(253)] Failed to export buffer to dma_buf: No such file or directory (2)
[12352:0629/172646.336769:ERROR:gbm_pixmap_wayland.cc(82)] Cannot create bo with format= RGBA_8888 and usage=SCANOUT
[12352:0629/172646.336875:ERROR:gbm_wrapper.cc(253)] Failed to export buffer to dma_buf: No such file or directory (2)
[12352:0629/172646.336912:ERROR:gbm_pixmap_wayland.cc(82)] Cannot create bo with format= RGBA_8888 and usage=GPU_READ
[12352:0629/172646.336945:ERROR:shared_image_factory.cc(926)] CreateSharedImage: could not create backing.
[12352:0629/172646.336979:ERROR:shared_image_factory.cc(758)] DestroySharedImage: Could not find shared image mailbox
[12352:0629/172646.337030:ERROR:gpu_service_impl.cc(1089)] Exiting GPU process because some drivers can't recover from errors. GPU process will restart shortly.
[4682:0629/172646.341410:ERROR:gpu_process_host.cc(991)] GPU process exited unexpectedly: exit_code=8704
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.

This is my Nvidia.nix file

{ config, lib, pkgs, ... }:

{

  options = {
    # Define any custom options here if needed.
  };

  config = {
    boot.kernelParams = [ "nvidia_drm.fbdev=1" "nvidia-drm.modeset=1" "module_blacklist=i915" ];

    hardware.opengl = {
      enable = true;
      driSupport = true;
      driSupport32Bit = true;
    };

    environment.systemPackages = with pkgs; [
      libva-utils
      vdpauinfo
      vulkan-tools
      vulkan-validation-layers
      libvdpau-va-gl
      egl-wayland
      wgpu-utils
      mesa
      libglvnd
      nvtop
      nvitop
      libGL
    ];

    services.xserver.videoDrivers = [ "nvidia" ];

    hardware.nvidia = {
      forceFullCompositionPipeline = true;
      modesetting.enable = true;
      powerManagement.enable = true;
      powerManagement.finegrained = false;
      open = false;
      nvidiaSettings = true;
      package = config.boot.kernelPackages.nvidiaPackages.production;
    };
  };
}

Mine works well, 24.05, GTX 1060M, x86-64, KDE6/Wayland with offloading on

{
  config,
  pkgs,
  ...
}: {
  # Enable OpenGL
  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {
    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    # Enable this if you have graphical corruption issues or application crashes after waking
    # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
    # of just the bare essentials.
    powerManagement.enable = false;

    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of
    # supported GPUs is at:
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
    # accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

  environment.systemPackages = with pkgs; [
    glxinfo
  ];

  hardware.nvidia.prime = {
    offload = {
      enable = true;
      enableOffloadCmd = true;
    };
  };
}

To help people debug your issue incude your nixpkgs branch, ardchitecture, gpu model, desktop environment, display manager, whether you have offloading on and link to a hardware probe: $ nix-shell -p hw-probe --command "sudo -E hw-probe -all -upload". Thanks.

This is a known issue with Logseq and Wayland. The overlay from this comment should fix it:

{ ... }:
{
  nixpkgs.overlays = [
    (final: prev: {
      logseq = prev.logseq.overrideAttrs (oldAttrs: {
        postFixup = ''
          makeWrapper ${prev.electron_27}/bin/electron $out/bin/${oldAttrs.pname} \
            --add-flags $out/share/${oldAttrs.pname}/resources/app \
            --add-flags "--use-gl=desktop" \
            --prefix LD_LIBRARY_PATH : "${prev.lib.makeLibraryPath [ prev.stdenv.cc.cc.lib ]}"
        '';
      });
    })
  ];
}

I was able to get it working by switching to 555 Nvidia driver and now it works. I used the instructions on this post

I still get the error though, but everything works as intended and is performant as expected

1 Like