about summary refs log tree commit diff
path: root/pkgs/tools/graphics/mangohud
diff options
context:
space:
mode:
authorKira Bruneau <kira.bruneau@pm.me>2023-04-14 13:12:08 -0400
committerKira Bruneau <kira.bruneau@pm.me>2023-04-23 13:14:00 -0400
commitd5355161f566b1fecfb3c79bb134ec78ac42d999 (patch)
tree2ef21bca8191562c791a363fa3f562bb63a780c0 /pkgs/tools/graphics/mangohud
parent2362848adf8def2866fabbffc50462e929d7fffb (diff)
mangohud: enable tests
Diffstat (limited to 'pkgs/tools/graphics/mangohud')
-rw-r--r--pkgs/tools/graphics/mangohud/default.nix30
1 files changed, 28 insertions, 2 deletions
diff --git a/pkgs/tools/graphics/mangohud/default.nix b/pkgs/tools/graphics/mangohud/default.nix
index af2619f9d18fb..5b6e5e8e76dea 100644
--- a/pkgs/tools/graphics/mangohud/default.nix
+++ b/pkgs/tools/graphics/mangohud/default.nix
@@ -1,5 +1,6 @@
 { lib
 , stdenv
+, fetchFromGitLab
 , fetchFromGitHub
 , fetchurl
 , substituteAll
@@ -13,6 +14,7 @@
 , hwdata
 , mangohud32
 , addOpenGLRunpath
+, appstream
 , glslang
 , mako
 , meson
@@ -32,6 +34,17 @@
 }:
 
 let
+  # Derived from subprojects/cmocka.wrap
+  cmocka = rec {
+    version = "1.81";
+    src = fetchFromGitLab {
+      owner = "cmocka";
+      repo = "cmocka";
+      rev = "59dc0013f9f29fcf212fe4911c78e734263ce24c";
+      hash = "sha256-IbAZOC0Q60PrKlKVWsgg/PFDV0PLb/yy+Iz/4Iziny0=";
+    };
+  };
+
   # Derived from subprojects/imgui.wrap
   imgui = rec {
     version = "1.81";
@@ -79,6 +92,9 @@ stdenv.mkDerivation (finalAttrs: {
   # Unpack subproject sources
   postUnpack = ''(
     cd "$sourceRoot/subprojects"
+    ${lib.optionalString finalAttrs.doCheck ''
+      cp -R --no-preserve=mode,ownership ${cmocka.src} cmocka
+    ''}
     cp -R --no-preserve=mode,ownership ${imgui.src} imgui-${imgui.version}
     cp -R --no-preserve=mode,ownership ${vulkan-headers.src} Vulkan-Headers-${vulkan-headers.version}
   )'';
@@ -127,7 +143,7 @@ stdenv.mkDerivation (finalAttrs: {
   mesonFlags = [
     "-Dwith_wayland=enabled"
     "-Duse_system_spdlog=enabled"
-    "-Dtests=disabled" # Tests require AMD GPU
+    "-Dtests=${if finalAttrs.doCheck then "enabled" else "disabled"}"
   ] ++ lib.optionals gamescopeSupport [
     "-Dmangoapp=true"
     "-Dmangoapp_layer=true"
@@ -160,6 +176,12 @@ stdenv.mkDerivation (finalAttrs: {
     xorg.libXrandr
   ];
 
+  doCheck = true;
+
+  nativeCheckInputs = [
+    appstream
+  ];
+
   # Support 32bit Vulkan applications by linking in 32bit Vulkan layers
   # This is needed for the same reason the 32bit preload workaround is needed.
   postInstall = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
@@ -172,12 +194,16 @@ stdenv.mkDerivation (finalAttrs: {
     ''}
   '';
 
-  # Add OpenGL driver path to RUNPATH to support NVIDIA cards
   postFixup = ''
+    # Add OpenGL driver path to RUNPATH to support NVIDIA cards
     addOpenGLRunpath "$out/lib/mangohud/libMangoHud.so"
     ${lib.optionalString gamescopeSupport ''
       addOpenGLRunpath "$out/bin/mangoapp"
     ''}
+    ${lib.optionalString finalAttrs.doCheck ''
+      # libcmocka.so is only used for tests
+      rm "$out/lib/libcmocka.so"
+    ''}
   '';
 
   passthru.updateScript = nix-update-script { };