2021-05-01 21:34:28 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-12-12 22:37:36 +01:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
2021-05-01 21:34:28 +02:00
|
|
|
, substituteAll
|
|
|
|
, coreutils
|
|
|
|
, curl
|
|
|
|
, gawk
|
|
|
|
, glxinfo
|
|
|
|
, gnugrep
|
|
|
|
, gnused
|
|
|
|
, pciutils
|
|
|
|
, xdg-utils
|
|
|
|
, dbus
|
|
|
|
, hwdata
|
|
|
|
, libX11
|
|
|
|
, mangohud32
|
|
|
|
, vulkan-headers
|
|
|
|
, glslang
|
|
|
|
, makeWrapper
|
2020-12-12 22:37:36 +01:00
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
, python3Packages
|
|
|
|
, vulkan-loader
|
2021-05-01 21:34:28 +02:00
|
|
|
, libXNVCtrl
|
2020-12-12 22:37:36 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2021-05-01 21:34:28 +02:00
|
|
|
pname = "mangohud";
|
|
|
|
version = "0.6.1";
|
2020-12-12 22:37:36 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "flightlessmango";
|
|
|
|
repo = "MangoHud";
|
|
|
|
rev = "v${version}";
|
2021-05-01 21:34:28 +02:00
|
|
|
sha256 = "1bzfp37qrx9kk5zaq7sfisgkyccwnxd7i3b1l0blfcy2lrxgx0n6";
|
2020-12-12 22:37:36 +01:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
2021-05-01 21:34:28 +02:00
|
|
|
# Adds option to specify Vulkan's datadir when it's not the same as MangoHud's
|
|
|
|
# See https://github.com/flightlessmango/MangoHud/pull/522
|
2020-12-12 22:37:36 +01:00
|
|
|
(fetchpatch {
|
2021-05-01 21:34:28 +02:00
|
|
|
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;
|
2020-12-12 22:37:36 +01:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
mesonFlags = [
|
|
|
|
"-Duse_system_vulkan=enabled"
|
2021-05-01 21:34:28 +02:00
|
|
|
"-Dvulkan_datadir=${vulkan-headers}/share"
|
2020-12-12 22:37:36 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-05-01 21:34:28 +02:00
|
|
|
glslang
|
|
|
|
makeWrapper
|
2020-12-12 22:37:36 +01:00
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
python3Packages.Mako
|
|
|
|
python3Packages.python
|
2021-05-01 21:34:28 +02:00
|
|
|
vulkan-loader
|
2020-12-12 22:37:36 +01:00
|
|
|
];
|
|
|
|
|
2021-05-01 21:34:28 +02:00
|
|
|
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
|
2020-12-12 22:37:36 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more";
|
|
|
|
homepage = "https://github.com/flightlessmango/MangoHud";
|
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.mit;
|
2021-05-22 16:47:40 +02:00
|
|
|
maintainers = with maintainers; [ kira-bruneau zeratax ];
|
2020-12-12 22:37:36 +01:00
|
|
|
};
|
|
|
|
}
|