Commit 1e41a945 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by Kira Bruneau
Browse files

mangohud: add option to disable x11 support

This avoids the following error (the application works anyway) on wayland only systems:
[2025-03-03 22:53:17.287] [MANGOHUD] [error] [loader_x11.cpp:19] Failed to open 64bit libX11.so.6: libX11.so.6: cannot open shared object file: No such file or directory
[2025-03-03 22:53:17.287] [MANGOHUD] [error] [shared_x11.cpp:23] X11 loader failed to load
parent c60fcad6
Loading
Loading
Loading
Loading
+23 −16
Original line number Diff line number Diff line
@@ -25,16 +25,20 @@
  wayland,
  nlohmann_json,
  spdlog,
  libxkbcommon,
  glew,
  glfw,
  xorg,
  x11Support ? true,
  nvidiaSupport ? true,
  gamescopeSupport ? true, # build mangoapp and mangohudctl
  lowerBitnessSupport ? stdenv.hostPlatform.isx86_64, # Support 32 bit on 64bit
  nix-update-script,
  libxkbcommon,
}:

assert lib.assertMsg (nvidiaSupport -> x11Support) "nvidiaSupport requires x11Support";
assert lib.assertMsg (gamescopeSupport -> x11Support) "gamescopeSupport requires x11Support";

let
  # Derived from subprojects/imgui.wrap
  imgui = rec {
@@ -162,6 +166,7 @@ stdenv.mkDerivation (finalAttrs: {
      "-Dwith_wayland=enabled"
      "-Duse_system_spdlog=enabled"
      "-Dtests=disabled" # amdgpu test segfaults in nix sandbox
      (lib.mesonEnable "with_x11" x11Support)
      (lib.mesonEnable "with_xnvctrl" nvidiaSupport)
    ]
    ++ lib.optionals gamescopeSupport [
@@ -169,7 +174,8 @@ stdenv.mkDerivation (finalAttrs: {
      "-Dmangohudctl=true"
    ];

  nativeBuildInputs = [
  nativeBuildInputs =
    [
      addDriverRunpath
      glslang
      mako
@@ -180,21 +186,22 @@ stdenv.mkDerivation (finalAttrs: {

      # Only the headers are used from these packages
      # The corresponding libraries are loaded at runtime from the app's runpath
    libX11
      wayland
  ] ++ lib.optional nvidiaSupport libXNVCtrl;
    ]
    ++ lib.optional x11Support libX11
    ++ lib.optional nvidiaSupport libXNVCtrl;

  buildInputs =
    [
      dbus
      nlohmann_json
      spdlog
      libxkbcommon # required by x11 or wayland support
    ]
    ++ lib.optionals gamescopeSupport [
      glew
      glfw
      xorg.libXrandr
      libxkbcommon
    ];

  doCheck = true;