|
| 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