mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 22:50:49 +00:00
mangohud: 0.4.1 → 0.6.1
This commit is contained in:
parent
6358647558
commit
c3a52c2a27
|
@ -1,14 +0,0 @@
|
|||
{ stdenv, pkgs, lib
|
||||
, libXNVCtrl
|
||||
}:
|
||||
let
|
||||
mangohud_64 = pkgs.callPackage ./default.nix { inherit libXNVCtrl; };
|
||||
mangohud_32 = pkgs.pkgsi686Linux.callPackage ./default.nix { inherit libXNVCtrl; };
|
||||
in
|
||||
pkgs.buildEnv rec {
|
||||
name = "mangohud-${mangohud_64.version}";
|
||||
|
||||
paths = [ mangohud_32 ] ++ lib.optionals stdenv.is64bit [ mangohud_64 ];
|
||||
|
||||
meta = mangohud_64.meta;
|
||||
}
|
|
@ -1,72 +1,118 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, substituteAll
|
||||
, coreutils
|
||||
, curl
|
||||
, gawk
|
||||
, glxinfo
|
||||
, gnugrep
|
||||
, gnused
|
||||
, pciutils
|
||||
, xdg-utils
|
||||
, dbus
|
||||
, hwdata
|
||||
, libX11
|
||||
, mangohud32
|
||||
, vulkan-headers
|
||||
, glslang
|
||||
, makeWrapper
|
||||
, meson
|
||||
, ninja
|
||||
, pkg-config
|
||||
, python3Packages
|
||||
, dbus
|
||||
, glslang
|
||||
, libglvnd
|
||||
, libXNVCtrl
|
||||
, mesa
|
||||
, vulkan-headers
|
||||
, vulkan-loader
|
||||
, xorg
|
||||
, libXNVCtrl
|
||||
}:
|
||||
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "mangohud${lib.optionalString stdenv.is32bit "_32"}";
|
||||
version = "0.4.1";
|
||||
pname = "mangohud";
|
||||
version = "0.6.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "flightlessmango";
|
||||
repo = "MangoHud";
|
||||
rev = "v${version}";
|
||||
sha256 = "04v2ps8n15ph2smjgnssax5hq88bszw2kbcff37cnd5c8yysvfi6";
|
||||
sha256 = "1bzfp37qrx9kk5zaq7sfisgkyccwnxd7i3b1l0blfcy2lrxgx0n6";
|
||||
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 {
|
||||
# FIXME obsolete in >=0.5.0
|
||||
url = "https://patch-diff.githubusercontent.com/raw/flightlessmango/MangoHud/pull/208.patch";
|
||||
sha256 = "1i6x6sr4az1zv0p6vpw99n947c7awgbbv087fghjlczhry676nmh";
|
||||
url = "https://github.com/flightlessmango/MangoHud/commit/56682985d8cec711af7ad0841888a44099249b1b.patch";
|
||||
sha256 = "0l5vb374lfgfh54jiy4097bzsccpv4zsl1fdhn55sxggklymcad8";
|
||||
})
|
||||
|
||||
# Hard code dependencies. Can't use makeWrapper since the Vulkan
|
||||
# layer can be used without the mangohud executable by setting MANGOHUD=1.
|
||||
(substituteAll {
|
||||
src = ./hardcode-dependencies.patch;
|
||||
|
||||
path = lib.makeBinPath [
|
||||
coreutils
|
||||
curl
|
||||
gawk
|
||||
glxinfo
|
||||
gnugrep
|
||||
gnused
|
||||
pciutils
|
||||
xdg-utils
|
||||
];
|
||||
|
||||
libdbus = dbus.lib;
|
||||
inherit hwdata libX11;
|
||||
})
|
||||
] ++ lib.optional (stdenv.hostPlatform.system == "x86_64-linux") [
|
||||
# Support 32bit OpenGL applications by appending the mangohud32
|
||||
# lib path to LD_LIBRARY_PATH.
|
||||
#
|
||||
# This workaround is necessary since on Nix's build of ld.so, $LIB
|
||||
# always expands to lib even when running an 32bit application.
|
||||
#
|
||||
# See https://github.com/NixOS/nixpkgs/issues/101597.
|
||||
(substituteAll {
|
||||
src = ./opengl32-nix-workaround.patch;
|
||||
inherit mangohud32;
|
||||
})
|
||||
];
|
||||
|
||||
mesonFlags = [
|
||||
"-Dappend_libdir_mangohud=false"
|
||||
"-Duse_system_vulkan=enabled"
|
||||
"--libdir=lib${lib.optionalString stdenv.is32bit "32"}"
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
dbus
|
||||
glslang
|
||||
libglvnd
|
||||
libXNVCtrl
|
||||
mesa
|
||||
python3Packages.Mako
|
||||
vulkan-headers
|
||||
vulkan-loader
|
||||
xorg.libX11
|
||||
"-Dvulkan_datadir=${vulkan-headers}/share"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
glslang
|
||||
makeWrapper
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
python3Packages.Mako
|
||||
python3Packages.python
|
||||
vulkan-loader
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
mkdir -p "$out/share/vulkan/"
|
||||
ln -sf "${vulkan-headers}/share/vulkan/registry/" $out/share/vulkan/
|
||||
ln -sf "${vulkan-headers}/include" $out
|
||||
buildInputs = [
|
||||
dbus
|
||||
libX11
|
||||
libXNVCtrl
|
||||
];
|
||||
|
||||
# Support 32bit Vulkan applications by linking in 32bit Vulkan layer
|
||||
# This is needed for the same reason the 32bit OpenGL workaround is needed.
|
||||
postInstall = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
|
||||
ln -s ${mangohud32}/share/vulkan/implicit_layer.d/MangoHud.json \
|
||||
"$out/share/vulkan/implicit_layer.d/MangoHud.x86.json"
|
||||
'';
|
||||
|
||||
# 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
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
@ -74,6 +120,6 @@ stdenv.mkDerivation rec {
|
|||
homepage = "https://github.com/flightlessmango/MangoHud";
|
||||
platforms = platforms.linux;
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ zeratax ];
|
||||
maintainers = with maintainers; [ metadark zeratax ];
|
||||
};
|
||||
}
|
||||
|
|
57
pkgs/tools/graphics/mangohud/hardcode-dependencies.patch
Normal file
57
pkgs/tools/graphics/mangohud/hardcode-dependencies.patch
Normal file
|
@ -0,0 +1,57 @@
|
|||
diff --git a/src/dbus.cpp b/src/dbus.cpp
|
||||
index 0acccc3..7dd7c49 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;
|
||||
}
|
||||
|
||||
- if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) {
|
||||
+ if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("@libdbus@/lib/libdbus-1.so.3")) {
|
||||
std::cerr << "MANGOHUD: Could not load libdbus-1.so.3\n";
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/loaders/loader_x11.cpp b/src/loaders/loader_x11.cpp
|
||||
index 25c65bf..87488d5 100644
|
||||
--- a/src/loaders/loader_x11.cpp
|
||||
+++ b/src/loaders/loader_x11.cpp
|
||||
@@ -88,4 +88,4 @@ void libx11_loader::CleanUp(bool unload) {
|
||||
|
||||
}
|
||||
|
||||
-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
|
||||
--- a/src/logging.cpp
|
||||
+++ b/src/logging.cpp
|
||||
@@ -17,7 +17,10 @@ string exec(string command) {
|
||||
string result = "";
|
||||
|
||||
// Open pipe to file
|
||||
+ char* originalPath = getenv("PATH");
|
||||
+ setenv("PATH", "@path@", 1);
|
||||
FILE* pipe = popen(command.c_str(), "r");
|
||||
+ setenv("PATH", originalPath, 1);
|
||||
if (!pipe) {
|
||||
return "popen failed!";
|
||||
}
|
||||
diff --git a/src/pci_ids.cpp b/src/pci_ids.cpp
|
||||
index 4e2a6d2..9490869 100644
|
||||
--- a/src/pci_ids.cpp
|
||||
+++ b/src/pci_ids.cpp
|
||||
@@ -22,12 +22,9 @@ std::istream& get_uncommented_line(std::istream& is, std::string &line)
|
||||
|
||||
void parse_pciids()
|
||||
{
|
||||
- std::ifstream file("/usr/share/hwdata/pci.ids");
|
||||
+ std::ifstream file("@hwdata@/share/hwdata/pci.ids");
|
||||
if(file.fail()){
|
||||
- std::ifstream file("/usr/share/misc/pci.ids");
|
||||
- if (file.fail())
|
||||
- printf("MANGOHUD: can't find file pci.ids\n");
|
||||
-
|
||||
+ printf("MANGOHUD: can't find file pci.ids\n");
|
||||
}
|
||||
|
||||
std::string line;
|
12
pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch
Normal file
12
pkgs/tools/graphics/mangohud/opengl32-nix-workaround.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
diff --git a/bin/mangohud.in b/bin/mangohud.in
|
||||
index eadce2d..e7b1aa4 100755
|
||||
--- a/bin/mangohud.in
|
||||
+++ b/bin/mangohud.in
|
||||
@@ -23,6 +23,6 @@ fi
|
||||
# figure out whether the 32 or 64 bit version should be used, and will search
|
||||
# for it in the correct directory
|
||||
LD_PRELOAD="${LD_PRELOAD}:${MANGOHUD_LIB_NAME}"
|
||||
-LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@"
|
||||
+LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@:@mangohud32@/lib/mangohud"
|
||||
|
||||
exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" "$@"
|
|
@ -6584,8 +6584,9 @@ in
|
|||
|
||||
mandoc = callPackage ../tools/misc/mandoc { };
|
||||
|
||||
mangohud = callPackage ../tools/graphics/mangohud/combined.nix {
|
||||
mangohud = callPackage ../tools/graphics/mangohud {
|
||||
libXNVCtrl = linuxPackages.nvidia_x11.settings.libXNVCtrl;
|
||||
mangohud32 = pkgsi686Linux.mangohud;
|
||||
};
|
||||
|
||||
manix = callPackage ../tools/nix/manix {
|
||||
|
|
Loading…
Reference in a new issue