From 76834c2bad2639fd96bb58442396e57b737b635a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Kurucz?= Date: Thu, 19 Dec 2024 22:15:08 +0100 Subject: [PATCH 1/2] apitrace: add enableGui option The motivation for this change is to be able to cross-compile apitrace, at least without the GUI. Fixing GUI cross-compilation is blocked by Note that we also move `python3` into `nativeBuildInputs`, which is also required to make cross-compilation work. --- pkgs/applications/graphics/apitrace/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/graphics/apitrace/default.nix b/pkgs/applications/graphics/apitrace/default.nix index 0aa3f79b001d..604f4a2393a5 100644 --- a/pkgs/applications/graphics/apitrace/default.nix +++ b/pkgs/applications/graphics/apitrace/default.nix @@ -13,6 +13,7 @@ libglvnd, gtest, brotli, + enableGui ? true, }: stdenv.mkDerivation rec { @@ -32,19 +33,25 @@ stdenv.mkDerivation rec { buildInputs = [ libX11 procps - python3 libdwarf - qtbase gtest brotli + ] ++ lib.optionals enableGui [ + qtbase ]; nativeBuildInputs = [ cmake pkg-config + python3 + ] ++ lib.optionals enableGui [ wrapQtAppsHook ]; + cmakeFlags = [ + (lib.cmakeBool "ENABLE_GUI" enableGui) + ]; + # Don't automatically wrap all binaries, I prefer to explicitly only wrap # `qapitrace`. dontWrapQtApps = true; @@ -83,6 +90,7 @@ stdenv.mkDerivation rec { patchelf --set-rpath "${lib.makeLibraryPath [ libglvnd ]}:$(patchelf --print-rpath $i)" $i done + '' + lib.optionalString enableGui '' wrapQtApp $out/bin/qapitrace ''; From a101d38330ef4c74a0f3fb3da61ba4ec7085d5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Kurucz?= Date: Sun, 23 Feb 2025 00:37:03 +0100 Subject: [PATCH 2/2] apitrace: reformat using nixfmt --- .../graphics/apitrace/default.nix | 106 +++++++++--------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/pkgs/applications/graphics/apitrace/default.nix b/pkgs/applications/graphics/apitrace/default.nix index 604f4a2393a5..6db2925644d5 100644 --- a/pkgs/applications/graphics/apitrace/default.nix +++ b/pkgs/applications/graphics/apitrace/default.nix @@ -30,23 +30,27 @@ stdenv.mkDerivation rec { # LD_PRELOAD wrappers need to be statically linked to work against all kinds # of games -- so it's fine to use e.g. bundled snappy. - buildInputs = [ - libX11 - procps - libdwarf - gtest - brotli - ] ++ lib.optionals enableGui [ - qtbase - ]; + buildInputs = + [ + libX11 + procps + libdwarf + gtest + brotli + ] + ++ lib.optionals enableGui [ + qtbase + ]; - nativeBuildInputs = [ - cmake - pkg-config - python3 - ] ++ lib.optionals enableGui [ - wrapQtAppsHook - ]; + nativeBuildInputs = + [ + cmake + pkg-config + python3 + ] + ++ lib.optionals enableGui [ + wrapQtAppsHook + ]; cmakeFlags = [ (lib.cmakeBool "ENABLE_GUI" enableGui) @@ -56,43 +60,45 @@ stdenv.mkDerivation rec { # `qapitrace`. dontWrapQtApps = true; - postFixup = '' + postFixup = + '' - # Since https://github.com/NixOS/nixpkgs/pull/60985, we add `/run-opengl-driver[-32]` - # to the `RUNPATH` of dispatcher libraries `dlopen()` ing OpenGL drivers. - # `RUNPATH` doesn't propagate throughout the whole application, but only - # from the module performing the `dlopen()`. - # - # Apitrace wraps programs by running them with `LD_PRELOAD` pointing to `.so` - # files in $out/lib/apitrace/wrappers. - # - # Theses wrappers effectively wrap the `dlopen()` calls from `libglvnd` - # and other dispatcher libraries, and run `dlopen()` by themselves. - # - # As `RUNPATH` doesn't propagate through the whole library, and they're now the - # library doing the real `dlopen()`, they also need to have - # `/run-opengl-driver[-32]` added to their `RUNPATH`. - # - # To stay simple, we add paths for 32 and 64 bits unconditionally. - # This doesn't have an impact on closure size, and if the 32 bit drivers - # are not available, that folder is ignored. - for i in $out/lib/apitrace/wrappers/*.so - do - echo "Patching OpenGL driver path for $i" - patchelf --set-rpath "/run/opengl-driver/lib:/run/opengl-driver-32/lib:$(patchelf --print-rpath $i)" $i - done + # Since https://github.com/NixOS/nixpkgs/pull/60985, we add `/run-opengl-driver[-32]` + # to the `RUNPATH` of dispatcher libraries `dlopen()` ing OpenGL drivers. + # `RUNPATH` doesn't propagate throughout the whole application, but only + # from the module performing the `dlopen()`. + # + # Apitrace wraps programs by running them with `LD_PRELOAD` pointing to `.so` + # files in $out/lib/apitrace/wrappers. + # + # Theses wrappers effectively wrap the `dlopen()` calls from `libglvnd` + # and other dispatcher libraries, and run `dlopen()` by themselves. + # + # As `RUNPATH` doesn't propagate through the whole library, and they're now the + # library doing the real `dlopen()`, they also need to have + # `/run-opengl-driver[-32]` added to their `RUNPATH`. + # + # To stay simple, we add paths for 32 and 64 bits unconditionally. + # This doesn't have an impact on closure size, and if the 32 bit drivers + # are not available, that folder is ignored. + for i in $out/lib/apitrace/wrappers/*.so + do + echo "Patching OpenGL driver path for $i" + patchelf --set-rpath "/run/opengl-driver/lib:/run/opengl-driver-32/lib:$(patchelf --print-rpath $i)" $i + done - # Theses open the OpenGL driver at runtime, but it is not listed as NEEDED libraries. They need - # a reference to libglvnd. - for i in $out/bin/eglretrace $out/bin/glretrace - do - echo "Patching RPath for $i" - patchelf --set-rpath "${lib.makeLibraryPath [ libglvnd ]}:$(patchelf --print-rpath $i)" $i - done + # Theses open the OpenGL driver at runtime, but it is not listed as NEEDED libraries. They need + # a reference to libglvnd. + for i in $out/bin/eglretrace $out/bin/glretrace + do + echo "Patching RPath for $i" + patchelf --set-rpath "${lib.makeLibraryPath [ libglvnd ]}:$(patchelf --print-rpath $i)" $i + done - '' + lib.optionalString enableGui '' - wrapQtApp $out/bin/qapitrace - ''; + '' + + lib.optionalString enableGui '' + wrapQtApp $out/bin/qapitrace + ''; meta = with lib; { homepage = "https://apitrace.github.io";