Merge pull request #288954 from kira-bruneau/mangohud

mangohud: 0.7.0 -> 0.7.1
This commit is contained in:
Kira Bruneau 2024-02-19 19:06:43 -05:00 committed by GitHub
commit 1ed5f4f920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 83 additions and 43 deletions

View File

@ -4,6 +4,7 @@
, fetchFromGitHub , fetchFromGitHub
, fetchurl , fetchurl
, substituteAll , substituteAll
, fetchpatch
, coreutils , coreutils
, curl , curl
, glxinfo , glxinfo
@ -38,7 +39,6 @@
let let
# Derived from subprojects/cmocka.wrap # Derived from subprojects/cmocka.wrap
cmocka = { cmocka = {
version = "1.81";
src = fetchFromGitLab { src = fetchFromGitLab {
owner = "cmocka"; owner = "cmocka";
repo = "cmocka"; repo = "cmocka";
@ -47,18 +47,33 @@ let
}; };
}; };
# Derived from subprojects/implot.wrap
implot = rec {
version = "0.16";
src = fetchFromGitHub {
owner = "epezent";
repo = "implot";
rev = "refs/tags/v${version}";
hash = "sha256-/wkVsgz3wiUVZBCgRl2iDD6GWb+AoHN+u0aeqHHgem0=";
};
patch = fetchurl {
url = "https://wrapdb.mesonbuild.com/v2/implot_${version}-1/get_patch";
hash = "sha256-HGsUYgZqVFL6UMHaHdR/7YQfKCMpcsgtd48pYpNlaMc=";
};
};
# Derived from subprojects/imgui.wrap # Derived from subprojects/imgui.wrap
imgui = rec { imgui = rec {
version = "1.81"; version = "1.89.9";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "ocornut"; owner = "ocornut";
repo = "imgui"; repo = "imgui";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-rRkayXk3xz758v6vlMSaUu5fui6NR8Md3njhDB0gJ18="; hash = "sha256-0k9jKrJUrG9piHNFQaBBY3zgNIKM23ZA879NY+MNYTU=";
}; };
patch = fetchurl { patch = fetchurl {
url = "https://wrapdb.mesonbuild.com/v2/imgui_${version}-1/get_patch"; url = "https://wrapdb.mesonbuild.com/v2/imgui_${version}-1/get_patch";
hash = "sha256-bQC0QmkLalxdj4mDEdqvvOFtNwz2T1MpTDuMXGYeQ18="; hash = "sha256-myEpDFl9dr+NTus/n/oCSxHZ6mxh6R1kjMyQtChD1YQ=";
}; };
}; };
@ -68,7 +83,7 @@ let
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "KhronosGroup"; owner = "KhronosGroup";
repo = "Vulkan-Headers"; repo = "Vulkan-Headers";
rev = "v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-5uyk2nMwV1MjXoa3hK/WUeGLwpINJJEvY16kc5DEaks="; hash = "sha256-5uyk2nMwV1MjXoa3hK/WUeGLwpINJJEvY16kc5DEaks=";
}; };
patch = fetchurl { patch = fetchurl {
@ -79,14 +94,14 @@ let
in in
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "mangohud"; pname = "mangohud";
version = "0.7.0"; version = "0.7.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "flightlessmango"; owner = "flightlessmango";
repo = "MangoHud"; repo = "MangoHud";
rev = "refs/tags/v${finalAttrs.version}"; rev = "refs/tags/v${finalAttrs.version}";
fetchSubmodules = true; fetchSubmodules = true;
hash = "sha256-KkMN7A3AcS/v+b9GCs0pI6MBBk3WwOMciaoiBzL5xOQ="; hash = "sha256-Gnq+1j+PFbeipAfXGnTq7wZdVQeG9R9vLAKZnZj7Bvs=";
}; };
outputs = [ "out" "doc" "man" ]; outputs = [ "out" "doc" "man" ];
@ -97,6 +112,7 @@ stdenv.mkDerivation (finalAttrs: {
${lib.optionalString finalAttrs.finalPackage.doCheck '' ${lib.optionalString finalAttrs.finalPackage.doCheck ''
cp -R --no-preserve=mode,ownership ${cmocka.src} cmocka cp -R --no-preserve=mode,ownership ${cmocka.src} cmocka
''} ''}
cp -R --no-preserve=mode,ownership ${implot.src} implot-${implot.version}
cp -R --no-preserve=mode,ownership ${imgui.src} imgui-${imgui.version} 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} cp -R --no-preserve=mode,ownership ${vulkan-headers.src} Vulkan-Headers-${vulkan-headers.version}
)''; )'';
@ -124,6 +140,13 @@ stdenv.mkDerivation (finalAttrs: {
libdbus = dbus.lib; libdbus = dbus.lib;
inherit hwdata; inherit hwdata;
}) })
# Add dep_vulkan to mangoapp and test_amdgpu to fix build failure
# TODO: Remove in next release
(fetchpatch {
url = "https://github.com/flightlessmango/MangoHud/commit/cba217ffaf93aea6acb4e59e3e46bf912f740ccf.patch";
hash = "sha256-1My4/EuSMpe3AFhhFOJr8rz/wnywp+BW+F4dSgxToe0=";
})
]; ];
postPatch = '' postPatch = ''
@ -138,6 +161,7 @@ stdenv.mkDerivation (finalAttrs: {
( (
cd subprojects cd subprojects
unzip ${implot.patch}
unzip ${imgui.patch} unzip ${imgui.patch}
unzip ${vulkan-headers.patch} unzip ${vulkan-headers.patch}
) )
@ -198,33 +222,36 @@ stdenv.mkDerivation (finalAttrs: {
''} ''}
''; '';
postFixup = let postFixup =
archMap = { let
"x86_64-linux" = "x86_64"; archMap = {
"i686-linux" = "x86"; "x86_64-linux" = "x86_64";
}; "i686-linux" = "x86";
layerPlatform = archMap."${stdenv.hostPlatform.system}" or null; };
# We need to give the different layers separate names or else the loader layerPlatform = archMap."${stdenv.hostPlatform.system}" or null;
# might try the 32-bit one first, fail and not attempt to load the 64-bit # We need to give the different layers separate names or else the loader
# layer under the same name. # might try the 32-bit one first, fail and not attempt to load the 64-bit
in lib.optionalString (layerPlatform != null) '' # layer under the same name.
substituteInPlace $out/share/vulkan/implicit_layer.d/MangoHud.${layerPlatform}.json \ in
--replace "VK_LAYER_MANGOHUD_overlay" "VK_LAYER_MANGOHUD_overlay_${toString stdenv.hostPlatform.parsed.cpu.bits}" lib.optionalString (layerPlatform != null) ''
'' + '' substituteInPlace $out/share/vulkan/implicit_layer.d/MangoHud.${layerPlatform}.json \
# Add OpenGL driver path to RUNPATH to support NVIDIA cards --replace "VK_LAYER_MANGOHUD_overlay" "VK_LAYER_MANGOHUD_overlay_${toString stdenv.hostPlatform.parsed.cpu.bits}"
addOpenGLRunpath "$out/lib/mangohud/libMangoHud.so" '' + ''
'' + lib.optionalString gamescopeSupport '' # Add OpenGL driver path to RUNPATH to support NVIDIA cards
addOpenGLRunpath "$out/bin/mangoapp" addOpenGLRunpath "$out/lib/mangohud/libMangoHud.so"
'' + lib.optionalString finalAttrs.finalPackage.doCheck '' '' + lib.optionalString gamescopeSupport ''
# libcmocka.so is only used for tests addOpenGLRunpath "$out/bin/mangoapp"
rm "$out/lib/libcmocka.so" '' + lib.optionalString finalAttrs.finalPackage.doCheck ''
''; # libcmocka.so is only used for tests
rm "$out/lib/libcmocka.so"
'';
passthru.updateScript = nix-update-script { }; passthru.updateScript = nix-update-script { };
meta = with lib; { meta = with lib; {
description = "A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more"; description = "A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more";
homepage = "https://github.com/flightlessmango/MangoHud"; homepage = "https://github.com/flightlessmango/MangoHud";
changelog = "https://github.com/flightlessmango/MangoHud/releases/tag/v${finalAttrs.version}";
platforms = platforms.linux; platforms = platforms.linux;
license = licenses.mit; license = licenses.mit;
maintainers = with maintainers; [ kira-bruneau zeratax ]; maintainers = with maintainers; [ kira-bruneau zeratax ];

View File

@ -12,7 +12,7 @@ index 7379af1..4eef3fe 100644
return false; return false;
} }
diff --git a/src/logging.cpp b/src/logging.cpp diff --git a/src/logging.cpp b/src/logging.cpp
index 046c847..42782be 100644 index ca33ee3..90d3638 100644
--- a/src/logging.cpp --- a/src/logging.cpp
+++ b/src/logging.cpp +++ b/src/logging.cpp
@@ -26,7 +26,11 @@ string exec(string command) { @@ -26,7 +26,11 @@ string exec(string command) {

View File

@ -1,26 +1,39 @@
diff --git a/bin/mangohud.in b/bin/mangohud.in diff --git a/bin/mangohud.in b/bin/mangohud.in
index 6c3c6e8..8847cdc 100755 index 53c72ef..18240ea 100755
--- a/bin/mangohud.in --- a/bin/mangohud.in
+++ b/bin/mangohud.in +++ b/bin/mangohud.in
@@ -8,10 +8,10 @@ if [ "$#" -eq 0 ]; then @@ -13,13 +13,15 @@ fi
exit 1 DISABLE_LD_PRELOAD="cs2.sh
fi some_other_exe"
-MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud_opengl.so" -MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud_opengl.so"
+LD_LIBRARY_PATH="@libraryPath@${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
+XDG_DATA_DIRS="@dataDir@${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
+MANGOHUD_LIB_NAME="libMangoHud_opengl.so" +MANGOHUD_LIB_NAME="libMangoHud_opengl.so"
if [ "$1" = "--dlsym" ]; then if [ "$1" = "--dlsym" ]; then
- MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}" - MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
+ MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}" + MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
shift shift # shift will only be executed if $1 is "--dlsym"
elif [ "$MANGOHUD_DLSYM" = "1" ]; then
- MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
+ MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
fi fi
@@ -31,5 +31,7 @@ case ":${LD_PRELOAD-}:" in if [ "$1" = "--version" ]; then
LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}${MANGOHUD_LIB_NAME}" @@ -41,7 +43,7 @@ for exe in $DISABLE_LD_PRELOAD; do
esac done
+LD_LIBRARY_PATH="@libraryPath@${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" if [ "$disable_preload" = true ]; then
+XDG_DATA_DIRS="@dataDir@${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" - exec env MANGOHUD=1 "$@"
+ exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" XDG_DATA_DIRS="${XDG_DATA_DIRS}" "$@"
else
# Make sure we don't append mangohud lib multiple times
# otherwise, this could cause issues with the steam runtime
@@ -54,5 +56,5 @@ else
LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}${MANGOHUD_LIB_NAME}"
esac
-exec env MANGOHUD=1 LD_PRELOAD="${LD_PRELOAD}" "$@" - exec env MANGOHUD=1 LD_PRELOAD="${LD_PRELOAD}" "$@"
+exec env MANGOHUD=1 LD_PRELOAD="${LD_PRELOAD}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" XDG_DATA_DIRS="${XDG_DATA_DIRS}" "$@" + exec env MANGOHUD=1 LD_PRELOAD="${LD_PRELOAD}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" XDG_DATA_DIRS="${XDG_DATA_DIRS}" "$@"
fi