diff --git a/pkgs/tools/graphics/mangohud/default.nix b/pkgs/tools/graphics/mangohud/default.nix index d491698cc40f..379e3cb22a07 100644 --- a/pkgs/tools/graphics/mangohud/default.nix +++ b/pkgs/tools/graphics/mangohud/default.nix @@ -21,19 +21,31 @@ pkg-config, unzip, libX11, - libXNVCtrl, wayland, + libXNVCtrl, nlohmann_json, spdlog, + libxkbcommon, glew, glfw, - xorg, - gamescopeSupport ? true, # build mangoapp and mangohudctl + libXrandr, + x11Support ? true, + waylandSupport ? true, + nvidiaSupport ? true, + gamescopeSupport ? true, + mangoappSupport ? gamescopeSupport, + mangohudctlSupport ? gamescopeSupport, lowerBitnessSupport ? stdenv.hostPlatform.isx86_64, # Support 32 bit on 64bit nix-update-script, - libxkbcommon, }: +assert lib.assertMsg ( + x11Support || waylandSupport +) "either x11Support or waylandSupport should be enabled"; + +assert lib.assertMsg (nvidiaSupport -> x11Support) "nvidiaSupport requires x11Support"; +assert lib.assertMsg (mangoappSupport -> x11Support) "mangoappSupport requires x11Support"; + let # Derived from subprojects/imgui.wrap imgui = rec { @@ -151,32 +163,31 @@ stdenv.mkDerivation (finalAttrs: { ) ''; - mesonFlags = + mesonFlags = [ + "-Duse_system_spdlog=enabled" + "-Dtests=disabled" # amdgpu test segfaults in nix sandbox + (lib.mesonEnable "with_x11" x11Support) + (lib.mesonEnable "with_wayland" waylandSupport) + (lib.mesonEnable "with_xnvctrl" nvidiaSupport) + (lib.mesonBool "mangoapp" mangoappSupport) + (lib.mesonBool "mangohudctl" mangohudctlSupport) + ]; + + nativeBuildInputs = [ - "-Dwith_wayland=enabled" - "-Duse_system_spdlog=enabled" - "-Dtests=disabled" # amdgpu test segfaults in nix sandbox + addDriverRunpath + glslang + mako + meson + ninja + pkg-config + unzip ] - ++ lib.optionals gamescopeSupport [ - "-Dmangoapp=true" - "-Dmangohudctl=true" - ]; - - nativeBuildInputs = [ - addDriverRunpath - glslang - mako - meson - ninja - pkg-config - unzip - # Only the headers are used from these packages # The corresponding libraries are loaded at runtime from the app's runpath - libX11 - libXNVCtrl - wayland - ]; + ++ lib.optional x11Support libX11 + ++ lib.optional waylandSupport wayland + ++ lib.optional nvidiaSupport libXNVCtrl; buildInputs = [ @@ -184,11 +195,11 @@ stdenv.mkDerivation (finalAttrs: { nlohmann_json spdlog ] - ++ lib.optionals gamescopeSupport [ + ++ lib.optional (x11Support || waylandSupport) libxkbcommon + ++ lib.optionals mangoappSupport [ glew glfw - xorg.libXrandr - libxkbcommon + libXrandr ]; doCheck = true; @@ -219,12 +230,12 @@ stdenv.mkDerivation (finalAttrs: { substituteInPlace $out/share/vulkan/implicit_layer.d/MangoHud.${layerPlatform}.json \ --replace-fail "VK_LAYER_MANGOHUD_overlay" "VK_LAYER_MANGOHUD_overlay_${toString stdenv.hostPlatform.parsed.cpu.bits}" '' - + '' + + lib.optionalString nvidiaSupport '' # Add OpenGL driver and libXNVCtrl paths to RUNPATH to support NVIDIA cards addDriverRunpath "$out/lib/mangohud/libMangoHud.so" patchelf --add-rpath ${libXNVCtrl}/lib "$out/lib/mangohud/libMangoHud.so" '' - + lib.optionalString gamescopeSupport '' + + lib.optionalString mangoappSupport '' addDriverRunpath "$out/bin/mangoapp" '';