3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/graphics/mangohud/default.nix

150 lines
3.5 KiB
Nix
Raw Normal View History

2021-05-01 20:34:28 +01:00
{ lib
, stdenv
2020-12-12 21:37:36 +00:00
, fetchFromGitHub
2021-06-19 15:54:43 +01:00
, fetchurl
2021-05-01 20:34:28 +01:00
, substituteAll
, coreutils
, curl
, gawk
, glxinfo
, gnugrep
, gnused
2021-06-19 15:54:43 +01:00
, lsof
2021-05-01 20:34:28 +01:00
, xdg-utils
, dbus
, hwdata
, libX11
, mangohud32
, vulkan-headers
, glslang
, makeWrapper
2020-12-12 21:37:36 +00:00
, meson
, ninja
, pkg-config
, python3Packages
2021-06-19 15:54:43 +01:00
, unzip
2020-12-12 21:37:36 +00:00
, vulkan-loader
2021-05-01 20:34:28 +01:00
, libXNVCtrl
2021-06-19 15:50:25 +01:00
, wayland
, addOpenGLRunpath
2020-12-12 21:37:36 +00:00
}:
2021-06-19 15:54:43 +01:00
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 {
2021-05-01 20:34:28 +01:00
pname = "mangohud";
2021-07-09 15:27:56 +01:00
version = "0.6.5";
2020-12-12 21:37:36 +00:00
src = fetchFromGitHub {
owner = "flightlessmango";
repo = "MangoHud";
rev = "v${version}";
fetchSubmodules = true;
2021-07-09 15:27:56 +01:00
sha256 = "sha256-RRtti0VnB6SXrpFYaEqANvpgvP/Dkvc+x/I40AXaspU=";
2020-12-12 21:37:36 +00:00
};
2021-06-19 15:50:36 +01:00
outputs = [ "out" "doc" "man" ];
2021-06-19 15:54:43 +01:00
# Unpack subproject sources
postUnpack = ''(
cd "$sourceRoot/subprojects"
cp -R --no-preserve=mode,ownership ${imgui.src} imgui-${imgui.version}
unzip ${imgui.patch}
)'';
2021-05-01 20:34:28 +01:00
2021-06-19 15:54:43 +01:00
patches = [
2021-05-01 20:34:28 +01:00
# 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
2021-06-19 15:54:43 +01:00
lsof
2021-05-01 20:34:28 +01:00
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 21:37:36 +00:00
})
];
mesonFlags = [
"-Duse_system_vulkan=enabled"
2021-05-01 20:34:28 +01:00
"-Dvulkan_datadir=${vulkan-headers}/share"
2021-06-19 15:50:25 +01:00
"-Dwith_wayland=enabled"
2020-12-12 21:37:36 +00:00
];
nativeBuildInputs = [
2021-05-01 20:34:28 +01:00
glslang
makeWrapper
2020-12-12 21:37:36 +00:00
meson
ninja
pkg-config
python3Packages.Mako
python3Packages.python
2021-06-19 15:54:43 +01:00
unzip
2021-05-01 20:34:28 +01:00
vulkan-loader
2020-12-12 21:37:36 +00:00
];
2021-05-01 20:34:28 +01:00
buildInputs = [
dbus
libX11
libXNVCtrl
2021-06-19 15:50:25 +01:00
wayland
2021-05-01 20:34:28 +01:00
];
# 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 Nvidia cards by adding OpenGL path and support overlaying
# Vulkan applications without requiring MangoHud to be installed
2021-05-01 20:34:28 +01:00
postFixup = ''
wrapProgram "$out/bin/mangohud" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ addOpenGLRunpath.driverLink ]} \
--prefix XDG_DATA_DIRS : "$out/share"
2020-12-12 21:37:36 +00: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;
maintainers = with maintainers; [ kira-bruneau zeratax ];
2020-12-12 21:37:36 +00:00
};
}