lol

Merge pull request #122465 from MetaDark/mangohud

mangohud: 0.4.1 → 0.6.1

authored by

davidak and committed by
GitHub
4beb9ae8 d34e5f64

+152 -50
-14
pkgs/tools/graphics/mangohud/combined.nix
··· 1 - { stdenv, pkgs, lib 2 - , libXNVCtrl 3 - }: 4 - let 5 - mangohud_64 = pkgs.callPackage ./default.nix { inherit libXNVCtrl; }; 6 - mangohud_32 = pkgs.pkgsi686Linux.callPackage ./default.nix { inherit libXNVCtrl; }; 7 - in 8 - pkgs.buildEnv rec { 9 - name = "mangohud-${mangohud_64.version}"; 10 - 11 - paths = [ mangohud_32 ] ++ lib.optionals stdenv.is64bit [ mangohud_64 ]; 12 - 13 - meta = mangohud_64.meta; 14 - }
+81 -35
pkgs/tools/graphics/mangohud/default.nix
··· 1 - { stdenv 2 - , lib 1 + { lib 2 + , stdenv 3 3 , fetchFromGitHub 4 4 , fetchpatch 5 + , substituteAll 6 + , coreutils 7 + , curl 8 + , gawk 9 + , glxinfo 10 + , gnugrep 11 + , gnused 12 + , pciutils 13 + , xdg-utils 14 + , dbus 15 + , hwdata 16 + , libX11 17 + , mangohud32 18 + , vulkan-headers 19 + , glslang 20 + , makeWrapper 5 21 , meson 6 22 , ninja 7 23 , pkg-config 8 24 , python3Packages 9 - , dbus 10 - , glslang 11 - , libglvnd 25 + , vulkan-loader 12 26 , libXNVCtrl 13 - , mesa 14 - , vulkan-headers 15 - , vulkan-loader 16 - , xorg 17 27 }: 18 - 19 28 20 29 stdenv.mkDerivation rec { 21 - pname = "mangohud${lib.optionalString stdenv.is32bit "_32"}"; 22 - version = "0.4.1"; 30 + pname = "mangohud"; 31 + version = "0.6.1"; 23 32 24 33 src = fetchFromGitHub { 25 34 owner = "flightlessmango"; 26 35 repo = "MangoHud"; 27 36 rev = "v${version}"; 28 - sha256 = "04v2ps8n15ph2smjgnssax5hq88bszw2kbcff37cnd5c8yysvfi6"; 37 + sha256 = "1bzfp37qrx9kk5zaq7sfisgkyccwnxd7i3b1l0blfcy2lrxgx0n6"; 29 38 fetchSubmodules = true; 30 39 }; 31 40 32 41 patches = [ 42 + # Adds option to specify Vulkan's datadir when it's not the same as MangoHud's 43 + # See https://github.com/flightlessmango/MangoHud/pull/522 33 44 (fetchpatch { 34 - # FIXME obsolete in >=0.5.0 35 - url = "https://patch-diff.githubusercontent.com/raw/flightlessmango/MangoHud/pull/208.patch"; 36 - sha256 = "1i6x6sr4az1zv0p6vpw99n947c7awgbbv087fghjlczhry676nmh"; 45 + url = "https://github.com/flightlessmango/MangoHud/commit/56682985d8cec711af7ad0841888a44099249b1b.patch"; 46 + sha256 = "0l5vb374lfgfh54jiy4097bzsccpv4zsl1fdhn55sxggklymcad8"; 47 + }) 48 + 49 + # Hard code dependencies. Can't use makeWrapper since the Vulkan 50 + # layer can be used without the mangohud executable by setting MANGOHUD=1. 51 + (substituteAll { 52 + src = ./hardcode-dependencies.patch; 53 + 54 + path = lib.makeBinPath [ 55 + coreutils 56 + curl 57 + gawk 58 + glxinfo 59 + gnugrep 60 + gnused 61 + pciutils 62 + xdg-utils 63 + ]; 64 + 65 + libdbus = dbus.lib; 66 + inherit hwdata libX11; 67 + }) 68 + ] ++ lib.optional (stdenv.hostPlatform.system == "x86_64-linux") [ 69 + # Support 32bit OpenGL applications by appending the mangohud32 70 + # lib path to LD_LIBRARY_PATH. 71 + # 72 + # This workaround is necessary since on Nix's build of ld.so, $LIB 73 + # always expands to lib even when running an 32bit application. 74 + # 75 + # See https://github.com/NixOS/nixpkgs/issues/101597. 76 + (substituteAll { 77 + src = ./opengl32-nix-workaround.patch; 78 + inherit mangohud32; 37 79 }) 38 80 ]; 39 81 40 82 mesonFlags = [ 41 - "-Dappend_libdir_mangohud=false" 42 83 "-Duse_system_vulkan=enabled" 43 - "--libdir=lib${lib.optionalString stdenv.is32bit "32"}" 44 - ]; 45 - 46 - buildInputs = [ 47 - dbus 48 - glslang 49 - libglvnd 50 - libXNVCtrl 51 - mesa 52 - python3Packages.Mako 53 - vulkan-headers 54 - vulkan-loader 55 - xorg.libX11 84 + "-Dvulkan_datadir=${vulkan-headers}/share" 56 85 ]; 57 86 58 87 nativeBuildInputs = [ 88 + glslang 89 + makeWrapper 59 90 meson 60 91 ninja 61 92 pkg-config 62 93 python3Packages.Mako 63 94 python3Packages.python 95 + vulkan-loader 64 96 ]; 65 97 66 - preConfigure = '' 67 - mkdir -p "$out/share/vulkan/" 68 - ln -sf "${vulkan-headers}/share/vulkan/registry/" $out/share/vulkan/ 69 - ln -sf "${vulkan-headers}/include" $out 98 + buildInputs = [ 99 + dbus 100 + libX11 101 + libXNVCtrl 102 + ]; 103 + 104 + # Support 32bit Vulkan applications by linking in 32bit Vulkan layer 105 + # This is needed for the same reason the 32bit OpenGL workaround is needed. 106 + postInstall = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") '' 107 + ln -s ${mangohud32}/share/vulkan/implicit_layer.d/MangoHud.json \ 108 + "$out/share/vulkan/implicit_layer.d/MangoHud.x86.json" 109 + ''; 110 + 111 + # Support overlaying Vulkan applications without requiring mangohud to be installed 112 + postFixup = '' 113 + wrapProgram "$out/bin/mangohud" \ 114 + --prefix VK_LAYER_PATH : "$out/share/vulkan/implicit_layer.d" \ 115 + --prefix VK_INSTANCE_LAYERS : VK_LAYER_MANGOHUD_overlay 70 116 ''; 71 117 72 118 meta = with lib; { ··· 74 120 homepage = "https://github.com/flightlessmango/MangoHud"; 75 121 platforms = platforms.linux; 76 122 license = licenses.mit; 77 - maintainers = with maintainers; [ zeratax ]; 123 + maintainers = with maintainers; [ metadark zeratax ]; 78 124 }; 79 125 }
+57
pkgs/tools/graphics/mangohud/hardcode-dependencies.patch
··· 1 + diff --git a/src/dbus.cpp b/src/dbus.cpp 2 + index 0acccc3..7dd7c49 100644 3 + --- a/src/dbus.cpp 4 + +++ b/src/dbus.cpp 5 + @@ -157,7 +157,7 @@ bool dbus_manager::init(const std::string& requested_player) { 6 + m_requested_player = "org.mpris.MediaPlayer2." + requested_player; 7 + } 8 + 9 + - if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) { 10 + + if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("@libdbus@/lib/libdbus-1.so.3")) { 11 + std::cerr << "MANGOHUD: Could not load libdbus-1.so.3\n"; 12 + return false; 13 + } 14 + diff --git a/src/loaders/loader_x11.cpp b/src/loaders/loader_x11.cpp 15 + index 25c65bf..87488d5 100644 16 + --- a/src/loaders/loader_x11.cpp 17 + +++ b/src/loaders/loader_x11.cpp 18 + @@ -88,4 +88,4 @@ void libx11_loader::CleanUp(bool unload) { 19 + 20 + } 21 + 22 + -std::shared_ptr<libx11_loader> g_x11(new libx11_loader("libX11.so.6")); 23 + +std::shared_ptr<libx11_loader> g_x11(new libx11_loader("@libX11@/lib/libX11.so.6")); 24 + diff --git a/src/logging.cpp b/src/logging.cpp 25 + index f2c4271..d33e793 100644 26 + --- a/src/logging.cpp 27 + +++ b/src/logging.cpp 28 + @@ -17,7 +17,10 @@ string exec(string command) { 29 + string result = ""; 30 + 31 + // Open pipe to file 32 + + char* originalPath = getenv("PATH"); 33 + + setenv("PATH", "@path@", 1); 34 + FILE* pipe = popen(command.c_str(), "r"); 35 + + setenv("PATH", originalPath, 1); 36 + if (!pipe) { 37 + return "popen failed!"; 38 + } 39 + diff --git a/src/pci_ids.cpp b/src/pci_ids.cpp 40 + index 4e2a6d2..9490869 100644 41 + --- a/src/pci_ids.cpp 42 + +++ b/src/pci_ids.cpp 43 + @@ -22,12 +22,9 @@ std::istream& get_uncommented_line(std::istream& is, std::string &line) 44 + 45 + void parse_pciids() 46 + { 47 + - std::ifstream file("/usr/share/hwdata/pci.ids"); 48 + + std::ifstream file("@hwdata@/share/hwdata/pci.ids"); 49 + if(file.fail()){ 50 + - std::ifstream file("/usr/share/misc/pci.ids"); 51 + - if (file.fail()) 52 + - printf("MANGOHUD: can't find file pci.ids\n"); 53 + - 54 + + printf("MANGOHUD: can't find file pci.ids\n"); 55 + } 56 + 57 + std::string line;
+12
pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch
··· 1 + diff --git a/bin/mangohud.in b/bin/mangohud.in 2 + index eadce2d..e7b1aa4 100755 3 + --- a/bin/mangohud.in 4 + +++ b/bin/mangohud.in 5 + @@ -23,6 +23,6 @@ fi 6 + # figure out whether the 32 or 64 bit version should be used, and will search 7 + # for it in the correct directory 8 + LD_PRELOAD="${LD_PRELOAD}:${MANGOHUD_LIB_NAME}" 9 + -LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@" 10 + +LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@:@mangohud32@/lib/mangohud" 11 + 12 + exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" "$@"
+2 -1
pkgs/top-level/all-packages.nix
··· 6609 6609 6610 6610 mandoc = callPackage ../tools/misc/mandoc { }; 6611 6611 6612 - mangohud = callPackage ../tools/graphics/mangohud/combined.nix { 6612 + mangohud = callPackage ../tools/graphics/mangohud { 6613 6613 libXNVCtrl = linuxPackages.nvidia_x11.settings.libXNVCtrl; 6614 + mangohud32 = pkgsi686Linux.mangohud; 6614 6615 }; 6615 6616 6616 6617 manix = callPackage ../tools/nix/manix {