Skip to content

Commit 3afb320

Browse files
committed
mangohud
1 parent 4b85fef commit 3afb320

File tree

4 files changed

+169
-6
lines changed

4 files changed

+169
-6
lines changed

flake.nix

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
(final: prev: {
7777
batocera = pkgs.callPackage ./packages/batocera { inherit batocera-src; };
7878
batocera-resolution = pkgs.callPackage ./packages/batocera/core/batocera-resolution { inherit batocera-src; };
79+
batocera-settings = pkgs.callPackage ./packages/batocera/core/batocera-settings { inherit batocera-src; };
7980

81+
mangohud = pkgs.callPackage ./packages/batocera/utils/mangohud { inherit batocera-src; };
8082
emulationstation-batocera = pkgs.callPackage ./overlays/emulationstation-batocera { };
81-
82-
batocera-settings = pkgs.callPackage ./packages/batocera/core/batocera-settings { inherit batocera-src; };
8383
})
8484
];
8585
};
@@ -288,6 +288,7 @@
288288
pkgs.batocera-resolution
289289
pkgs.batocera-settings
290290

291+
pkgs.mangohud
291292
pkgs.emulationstation-batocera
292293
];
293294

packages/batocera/core/batocera-settings/default.nix

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# package/batocera/core/batocera-settings
21
{ lib
32
, stdenv
43
, batocera-src

packages/batocera/default.nix

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{ lib
2-
, writeTextFile
32
, stdenv
3+
, batocera-src
44
, makeWrapper
5-
, python311Packages
5+
, writeTextFile
66

77
, python311
8+
, python311Packages
89
, rsync
910

10-
, batocera-src
1111
, emus ? [ "BR2_PACKAGE_LIBRETRO_SNES9X" ]
1212
}:
1313

@@ -32,7 +32,11 @@ let
3232
patchPhase = ''
3333
runHook prePatch
3434
35+
substituteInPlace configgen/batoceraFiles.py \
36+
--replace-fail "retroarchCores = \"/usr/lib/libretro/\"" "retroarchCores = \"/run/current-system/sw/lib/retroarch/cores/\""
3537
find ./ -type f -exec sed -i -e 's|/usr/share/|/run/current-system/sw/share/|g' {} \;
38+
find ./ -type f -exec sed -i -e 's|/usr/bin/|/run/current-system/sw/bin/|g' {} \;
39+
find ./ -type f -exec sed -i -e 's|/usr/lib/libretro|/run/current-system/sw/lib/retroarch|g' {} \;
3640
3741
runHook postPatch
3842
'';
@@ -52,7 +56,11 @@ stdenv.mkDerivation (finalAttrs: {
5256
runHook prePatch
5357
5458
pushd package/batocera/core/batocera-configgen/configgen
59+
substituteInPlace configgen/batoceraFiles.py \
60+
--replace-fail "retroarchCores = \"/usr/lib/libretro/\"" "retroarchCores = \"/run/current-system/sw/lib/retroarch/cores/\""
5561
find . -type f -exec sed -i -e 's|/usr/share/|/run/current-system/sw/share/|g' {} \;
62+
find . -type f -exec sed -i -e 's|/usr/bin/|/run/current-system/sw/bin/|g' {} \;
63+
find . -type f -exec sed -i -e 's|/usr/lib/libretro|/run/current-system/sw/lib/retroarch|g' {} \;
5664
popd
5765
5866
runHook postPatch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
{ lib
2+
, stdenv
3+
, batocera-src
4+
, fetchFromGitHub
5+
, fetchurl
6+
7+
, meson
8+
, ninja
9+
, pkg-config
10+
, unzip
11+
, glslang
12+
, python311
13+
, python311Packages
14+
, libdrm
15+
, libX11
16+
, dbus
17+
18+
, enableDrm ? true
19+
, enableVulkan ? true
20+
, enableXorg ? true
21+
, enableWayland ? false
22+
}:
23+
24+
let
25+
python3 = python311;
26+
python3Packages = python311Packages;
27+
28+
imgui = rec {
29+
version = "1.81";
30+
fs-name = "imgui-${imgui.version}";
31+
src = fetchFromGitHub {
32+
owner = "ocornut";
33+
repo = "imgui";
34+
rev = "refs/tags/v${version}";
35+
hash = "sha256-rRkayXk3xz758v6vlMSaUu5fui6NR8Md3njhDB0gJ18=";
36+
};
37+
patch = fetchurl {
38+
url = "https://wrapdb.mesonbuild.com/v2/imgui_${version}-1/get_patch";
39+
hash = "sha256-bQC0QmkLalxdj4mDEdqvvOFtNwz2T1MpTDuMXGYeQ18=";
40+
};
41+
};
42+
43+
spdlog = rec {
44+
version = "1.8.5";
45+
fs-name = "spdlog-${spdlog.version}";
46+
src = fetchFromGitHub {
47+
owner = "gabime";
48+
repo = "spdlog";
49+
rev = "refs/tags/v${version}";
50+
hash = "sha256-D29jvDZQhPscaOHlrzGN1s7/mXlcsovjbqYpXd7OM50=";
51+
};
52+
patch = fetchurl {
53+
url = "https://wrapdb.mesonbuild.com/v2/spdlog_${version}-1/get_patch";
54+
hash = "sha256-PDjyddV5KxKGORECWUMp6YsXc3kks0T5gxKrCZKbdL4=";
55+
};
56+
};
57+
58+
vulkan-headers = rec {
59+
version = "1.2.158";
60+
fs-name = "Vulkan-Headers-${vulkan-headers.version}";
61+
src = fetchFromGitHub {
62+
owner = "KhronosGroup";
63+
repo = "Vulkan-Headers";
64+
rev = "refs/tags/v${version}";
65+
hash = "sha256-5uyk2nMwV1MjXoa3hK/WUeGLwpINJJEvY16kc5DEaks=";
66+
};
67+
patch = fetchurl {
68+
url = "https://wrapdb.mesonbuild.com/v2/vulkan-headers_${version}-2/get_patch";
69+
hash = "sha256-hgNYz15z9FjNHoj4w4EW0SOrQh1c4uQSnsOOrt2CDhc=";
70+
};
71+
};
72+
73+
subprojects = [ imgui spdlog vulkan-headers ];
74+
in
75+
stdenv.mkDerivation (finalAttrs: {
76+
pname = "mangohud";
77+
78+
version = "2021-10-01";
79+
80+
src = fetchFromGitHub {
81+
owner = "flightlessmango";
82+
repo = "MangoHud";
83+
rev = "a8a0a245e69fbbca5263d2436fd1c04289375498";
84+
hash = "sha256-eOaYKFTYK2hs1DCaAWW4w6ugN3pZ2qWxE3VIjew4+tM=";
85+
};
86+
87+
postUnpack = ''(
88+
cd "$sourceRoot/subprojects"
89+
90+
${lib.concatMapStrings
91+
(sub: "cp -R --no-preserve=mode,ownership ${sub.src} ${sub.fs-name}\n")
92+
subprojects}
93+
)'';
94+
95+
patches = [
96+
"${batocera-src}/package/batocera/utils/mangohud/0001-vulkan-Per-device-font-image-s.patch"
97+
"${batocera-src}/package/batocera/utils/mangohud/0002-WIP-separate-transfer-queue-command.patch"
98+
"${batocera-src}/package/batocera/utils/mangohud/0003-add-stb_image-and-stb_image_resize.patch"
99+
"${batocera-src}/package/batocera/utils/mangohud/0004-add-load-textures-functions.patch"
100+
"${batocera-src}/package/batocera/utils/mangohud/0005-convert-textures-to-rgba.patch"
101+
"${batocera-src}/package/batocera/utils/mangohud/0006-options-image-path-image_max_width-int-image_backgro.patch"
102+
"${batocera-src}/package/batocera/utils/mangohud/0007-Option-to-use-vulkan.patch"
103+
"${batocera-src}/package/batocera/utils/mangohud/0008-mangohud-on-drm.patch"
104+
"${batocera-src}/package/batocera/utils/mangohud/0009-desc-pool-flag.patch"
105+
"${batocera-src}/package/batocera/utils/mangohud/0010-wip-single-params.patch"
106+
"${batocera-src}/package/batocera/utils/mangohud/0011-wip-images.patch"
107+
"${batocera-src}/package/batocera/utils/mangohud/0012-wip-notifier.patch"
108+
"${batocera-src}/package/batocera/utils/mangohud/0013-wip-set-image-unloaded.patch"
109+
"${batocera-src}/package/batocera/utils/mangohud/0014-wip-simpler-locking-q.patch"
110+
];
111+
112+
postPatch = ''
113+
substituteInPlace bin/mangohud.in \
114+
--subst-var-by libraryPath ${lib.makeSearchPath "lib/mangohud" ([
115+
(placeholder "out")
116+
])} \
117+
--subst-var-by version "${finalAttrs.version}" \
118+
--subst-var-by dataDir ${placeholder "out"}/share
119+
120+
(
121+
cd subprojects
122+
${lib.concatMapStrings
123+
(sub: "unzip ${sub.patch}\n")
124+
subprojects}
125+
)
126+
'';
127+
128+
nativeBuildInputs = [
129+
meson
130+
ninja
131+
pkg-config
132+
unzip
133+
glslang
134+
python3
135+
python3Packages.mako
136+
] ++ (lib.optional enableXorg libX11);
137+
138+
buildInputs = [ dbus ]
139+
++ (lib.optional enableDrm libdrm);
140+
# ++ (lib.optional enableVulkan vulkan-headers);
141+
# ++ (lib.optional enableXorg xorg.xorgserver);
142+
143+
mesonFlags = [
144+
"-Dwith_xnvctrl=disabled"
145+
"-Duse_vulkan=${if enableVulkan then "true" else "false"}"
146+
"-Dwith_x11=${if enableXorg then "enabled" else "disabled"}"
147+
"-Dwith_wayland=${if enableWayland then "enabled" else "disabled"}"
148+
];
149+
150+
# postInstall = ''
151+
# install -m 0755 ${batocera-src}/package/batocera/core/batocera-settings/batocera-settings-get-master $out/bin/batocera-settings-get-master
152+
# substituteInPlace $out/bin/batocera-settings-get-master \
153+
# --replace-fail "/usr/" "/run/current-system/sw/"
154+
# '';
155+
})

0 commit comments

Comments
 (0)