Merge pull request #127469 from kira-bruneau/mangohud

This commit is contained in:
Sandro 2021-06-20 18:26:57 +02:00 committed by GitHub
commit 92e9653aa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 23 deletions

View file

@ -1,7 +1,7 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, fetchurl
, substituteAll
, coreutils
, curl
@ -9,7 +9,7 @@
, glxinfo
, gnugrep
, gnused
, pciutils
, lsof
, xdg-utils
, dbus
, hwdata
@ -22,30 +22,50 @@
, ninja
, pkg-config
, python3Packages
, unzip
, vulkan-loader
, libXNVCtrl
, wayland
, addOpenGLRunpath
}:
stdenv.mkDerivation rec {
let
# Derived from subprojects/imgui.wrap
imgui = rec {
version = "1.81";
src = fetchFromGitHub {
owner = "ocornut";
repo = "imgui";
rev = "v${version}";
hash = "sha256-rRkayXk3xz758v6vlMSaUu5fui6NR8Md3njhDB0gJ18=";
};
patch = fetchurl {
url = "https://wrapdb.mesonbuild.com/v2/imgui_${version}-1/get_patch";
hash = "sha256-bQC0QmkLalxdj4mDEdqvvOFtNwz2T1MpTDuMXGYeQ18=";
};
};
in stdenv.mkDerivation rec {
pname = "mangohud";
version = "0.6.1";
version = "0.6.3";
src = fetchFromGitHub {
owner = "flightlessmango";
repo = "MangoHud";
rev = "v${version}";
sha256 = "1bzfp37qrx9kk5zaq7sfisgkyccwnxd7i3b1l0blfcy2lrxgx0n6";
sha256 = "wL+/wAqvVFph1QzuXPBbSEFjs33VA0S6euNWr/1J1Mk=";
fetchSubmodules = true;
};
patches = [
# Adds option to specify Vulkan's datadir when it's not the same as MangoHud's
# See https://github.com/flightlessmango/MangoHud/pull/522
(fetchpatch {
url = "https://github.com/flightlessmango/MangoHud/commit/56682985d8cec711af7ad0841888a44099249b1b.patch";
sha256 = "0l5vb374lfgfh54jiy4097bzsccpv4zsl1fdhn55sxggklymcad8";
})
outputs = [ "out" "doc" "man" ];
# Unpack subproject sources
postUnpack = ''(
cd "$sourceRoot/subprojects"
cp -R --no-preserve=mode,ownership ${imgui.src} imgui-${imgui.version}
unzip ${imgui.patch}
)'';
patches = [
# Hard code dependencies. Can't use makeWrapper since the Vulkan
# layer can be used without the mangohud executable by setting MANGOHUD=1.
(substituteAll {
@ -58,7 +78,7 @@ stdenv.mkDerivation rec {
glxinfo
gnugrep
gnused
pciutils
lsof
xdg-utils
];
@ -82,6 +102,7 @@ stdenv.mkDerivation rec {
mesonFlags = [
"-Duse_system_vulkan=enabled"
"-Dvulkan_datadir=${vulkan-headers}/share"
"-Dwith_wayland=enabled"
];
nativeBuildInputs = [
@ -92,6 +113,7 @@ stdenv.mkDerivation rec {
pkg-config
python3Packages.Mako
python3Packages.python
unzip
vulkan-loader
];
@ -99,6 +121,7 @@ stdenv.mkDerivation rec {
dbus
libX11
libXNVCtrl
wayland
];
# Support 32bit Vulkan applications by linking in 32bit Vulkan layer
@ -108,11 +131,12 @@ stdenv.mkDerivation rec {
"$out/share/vulkan/implicit_layer.d/MangoHud.x86.json"
'';
# Support overlaying Vulkan applications without requiring mangohud to be installed
# Support Nvidia cards by adding OpenGL path and support overlaying
# Vulkan applications without requiring MangoHud to be installed
postFixup = ''
wrapProgram "$out/bin/mangohud" \
--prefix VK_LAYER_PATH : "$out/share/vulkan/implicit_layer.d" \
--prefix VK_INSTANCE_LAYERS : VK_LAYER_MANGOHUD_overlay
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ addOpenGLRunpath.driverLink ]} \
--prefix XDG_DATA_DIRS : "$out/share"
'';
meta = with lib; {

View file

@ -1,9 +1,9 @@
diff --git a/src/dbus.cpp b/src/dbus.cpp
index 0acccc3..7dd7c49 100644
index 44ffafc..9baf57b 100644
--- a/src/dbus.cpp
+++ b/src/dbus.cpp
@@ -157,7 +157,7 @@ bool dbus_manager::init(const std::string& requested_player) {
m_requested_player = "org.mpris.MediaPlayer2." + requested_player;
@@ -162,7 +162,7 @@ bool dbus_manager::init(const std::string& requested_player) {
return true;
}
- if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) {
@ -22,11 +22,11 @@ index 25c65bf..87488d5 100644
-std::shared_ptr<libx11_loader> g_x11(new libx11_loader("libX11.so.6"));
+std::shared_ptr<libx11_loader> g_x11(new libx11_loader("@libX11@/lib/libX11.so.6"));
diff --git a/src/logging.cpp b/src/logging.cpp
index f2c4271..d33e793 100644
index ee8600b..c7c91a0 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -17,7 +17,10 @@ string exec(string command) {
string result = "";
@@ -19,7 +19,10 @@ string exec(string command) {
#ifdef __gnu_linux__
// Open pipe to file
+ char* originalPath = getenv("PATH");

View file

@ -1,5 +1,5 @@
diff --git a/bin/mangohud.in b/bin/mangohud.in
index eadce2d..e7b1aa4 100755
index 8ec21de..f65304a 100755
--- a/bin/mangohud.in
+++ b/bin/mangohud.in
@@ -23,6 +23,6 @@ fi