diff --git a/pkgs/tools/graphics/mangohud/default.nix b/pkgs/tools/graphics/mangohud/default.nix index a69f8775f3b5..1015b4cd1bd4 100644 --- a/pkgs/tools/graphics/mangohud/default.nix +++ b/pkgs/tools/graphics/mangohud/default.nix @@ -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,33 +22,49 @@ , ninja , pkg-config , python3Packages +, unzip , vulkan-loader , libXNVCtrl , wayland }: -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; }; outputs = [ "out" "doc" "man" ]; - 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"; - }) + # 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 { @@ -61,7 +77,7 @@ stdenv.mkDerivation rec { glxinfo gnugrep gnused - pciutils + lsof xdg-utils ]; @@ -96,6 +112,7 @@ stdenv.mkDerivation rec { pkg-config python3Packages.Mako python3Packages.python + unzip vulkan-loader ]; diff --git a/pkgs/tools/graphics/mangohud/hardcode-dependencies.patch b/pkgs/tools/graphics/mangohud/hardcode-dependencies.patch index bdebcdca9821..2ee5e2dd5477 100644 --- a/pkgs/tools/graphics/mangohud/hardcode-dependencies.patch +++ b/pkgs/tools/graphics/mangohud/hardcode-dependencies.patch @@ -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 g_x11(new libx11_loader("libX11.so.6")); +std::shared_ptr 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"); diff --git a/pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch b/pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch index 3c0f6908617f..4c6561180a13 100644 --- a/pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch +++ b/pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch @@ -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