|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + SDL2, |
| 5 | + autoconf, |
| 6 | + boost, |
| 7 | + catch2_3, |
| 8 | + cmake, |
| 9 | + fetchFromGitHub, |
| 10 | + cpp-jwt, |
| 11 | + cubeb, |
| 12 | + discord-rpc, |
| 13 | + enet, |
| 14 | + fetchgit, |
| 15 | + fetchurl, |
| 16 | + ffmpeg-headless, |
| 17 | + fmt, |
| 18 | + glslang, |
| 19 | + libopus, |
| 20 | + libusb1, |
| 21 | + libva, |
| 22 | + lz4, |
| 23 | + python3, |
| 24 | + unzip, |
| 25 | + nix-update-script, |
| 26 | + nlohmann_json, |
| 27 | + nv-codec-headers-12, |
| 28 | + pkg-config, |
| 29 | + qt6, |
| 30 | + vulkan-headers, |
| 31 | + vulkan-loader, |
| 32 | + yasm, |
| 33 | + simpleini, |
| 34 | + zlib, |
| 35 | + vulkan-memory-allocator, |
| 36 | + zstd, |
| 37 | +}: |
| 38 | + |
| 39 | +let |
| 40 | + inherit (qt6) |
| 41 | + qtbase |
| 42 | + qtmultimedia |
| 43 | + qtwayland |
| 44 | + wrapQtAppsHook |
| 45 | + qttools |
| 46 | + qtwebengine |
| 47 | + ; |
| 48 | + |
| 49 | + compat-list = stdenv.mkDerivation { |
| 50 | + pname = "yuzu-compatibility-list"; |
| 51 | + version = "unstable-2024-02-26"; |
| 52 | + |
| 53 | + src = fetchFromGitHub { |
| 54 | + owner = "flathub"; |
| 55 | + repo = "org.yuzu_emu.yuzu"; |
| 56 | + rev = "9c2032a3c7e64772a8112b77ed8b660242172068"; |
| 57 | + hash = "sha256-ITh/W4vfC9w9t+TJnPeTZwWifnhTNKX54JSSdpgaoBk="; |
| 58 | + }; |
| 59 | + |
| 60 | + buildCommand = '' |
| 61 | + cp $src/compatibility_list.json $out |
| 62 | + ''; |
| 63 | + }; |
| 64 | + |
| 65 | + nx_tzdb = stdenv.mkDerivation rec { |
| 66 | + pname = "nx_tzdb"; |
| 67 | + version = "221202"; |
| 68 | + |
| 69 | + src = fetchurl { |
| 70 | + url = "https://github.com/lat9nq/tzdb_to_nx/releases/download/${version}/${version}.zip"; |
| 71 | + hash = "sha256-mRzW+iIwrU1zsxHmf+0RArU8BShAoEMvCz+McXFFK3c="; |
| 72 | + }; |
| 73 | + |
| 74 | + nativeBuildInputs = [ unzip ]; |
| 75 | + |
| 76 | + buildCommand = '' |
| 77 | + unzip $src -d $out |
| 78 | + ''; |
| 79 | + |
| 80 | + }; |
| 81 | + |
| 82 | +in |
| 83 | + |
| 84 | +stdenv.mkDerivation (finalAttrs: { |
| 85 | + pname = "torzu"; |
| 86 | + version = "unstable-2024-12-15"; |
| 87 | + |
| 88 | + src = fetchgit { |
| 89 | + url = "https://notabug.org/litucks/torzu"; |
| 90 | + rev = "02cfee3f184e6fdcc3b483ef399fb5d2bb1e8ec7"; |
| 91 | + hash = "sha256-hAWMFzTNJGFcrXov5LKMdW9YWhsu7wueATmiuS7EVkI="; |
| 92 | + fetchSubmodules = true; |
| 93 | + }; |
| 94 | + |
| 95 | + patches = [ |
| 96 | + # Remove coroutines from debugger to fix boost::asio compatibility issues |
| 97 | + ./fix-debugger.patch |
| 98 | + # Add explicit cast for CRC checksum value |
| 99 | + ./fix-udp-protocol.patch |
| 100 | + # Use specific boost::asio includes and update to modern io_context |
| 101 | + ./fix-udp-client.patch |
| 102 | + ]; |
| 103 | + |
| 104 | + nativeBuildInputs = [ |
| 105 | + cmake |
| 106 | + glslang |
| 107 | + pkg-config |
| 108 | + python3 |
| 109 | + qttools |
| 110 | + wrapQtAppsHook |
| 111 | + ]; |
| 112 | + |
| 113 | + buildInputs = [ |
| 114 | + # vulkan-headers must come first, so the older propagated versions |
| 115 | + # don't get picked up by accident |
| 116 | + vulkan-headers |
| 117 | + |
| 118 | + boost |
| 119 | + catch2_3 |
| 120 | + cpp-jwt |
| 121 | + cubeb |
| 122 | + discord-rpc |
| 123 | + # intentionally omitted: dynarmic - prefer vendored version for compatibility |
| 124 | + enet |
| 125 | + |
| 126 | + # ffmpeg deps (also includes vendored) |
| 127 | + # we do not use internal ffmpeg because cuda errors |
| 128 | + autoconf |
| 129 | + yasm |
| 130 | + libva # for accelerated video decode on non-nvidia |
| 131 | + nv-codec-headers-12 # for accelerated video decode on nvidia |
| 132 | + ffmpeg-headless |
| 133 | + # end ffmpeg deps |
| 134 | + |
| 135 | + fmt |
| 136 | + # intentionally omitted: gamemode - loaded dynamically at runtime |
| 137 | + # intentionally omitted: httplib - upstream requires an older version than what we have |
| 138 | + libopus |
| 139 | + libusb1 |
| 140 | + # intentionally omitted: LLVM - heavy, only used for stack traces in the debugger |
| 141 | + lz4 |
| 142 | + nlohmann_json |
| 143 | + qtbase |
| 144 | + qtmultimedia |
| 145 | + qtwayland |
| 146 | + qtwebengine |
| 147 | + # intentionally omitted: renderdoc - heavy, developer only |
| 148 | + SDL2 |
| 149 | + # intentionally omitted: stb - header only libraries, vendor uses git snapshot |
| 150 | + vulkan-memory-allocator |
| 151 | + # intentionally omitted: xbyak - prefer vendored version for compatibility |
| 152 | + zlib |
| 153 | + zstd |
| 154 | + ]; |
| 155 | + |
| 156 | + # This changes `ir/opt` to `ir/var/empty` in `externals/dynarmic/src/dynarmic/CMakeLists.txt` |
| 157 | + # making the build fail, as that path does not exist |
| 158 | + dontFixCmake = true; |
| 159 | + |
| 160 | + cmakeFlags = [ |
| 161 | + # actually has a noticeable performance impact |
| 162 | + (lib.cmakeBool "YUZU_ENABLE_LTO" true) |
| 163 | + (lib.cmakeBool "YUZU_TESTS" false) |
| 164 | + |
| 165 | + (lib.cmakeBool "ENABLE_QT6" true) |
| 166 | + (lib.cmakeBool "ENABLE_QT_TRANSLATION" true) |
| 167 | + |
| 168 | + # use system libraries |
| 169 | + # NB: "external" here means "from the externals/ directory in the source", |
| 170 | + # so "off" means "use system" |
| 171 | + (lib.cmakeBool "YUZU_USE_EXTERNAL_SDL2" false) |
| 172 | + (lib.cmakeBool "YUZU_USE_EXTERNAL_VULKAN_HEADERS" true) |
| 173 | + "-DVulkan_INCLUDE_DIRS=${vulkan-headers}/include" |
| 174 | + |
| 175 | + # # don't use system ffmpeg, suyu uses internal APIs |
| 176 | + # (lib.cmakeBool "YUZU_USE_BUNDLED_FFMPEG" true) |
| 177 | + |
| 178 | + # don't check for missing submodules |
| 179 | + (lib.cmakeBool "YUZU_CHECK_SUBMODULES" false) |
| 180 | + |
| 181 | + # enable some optional features |
| 182 | + (lib.cmakeBool "YUZU_USE_QT_WEB_ENGINE" true) |
| 183 | + (lib.cmakeBool "YUZU_USE_QT_MULTIMEDIA" true) |
| 184 | + (lib.cmakeBool "USE_DISCORD_PRESENCE" true) |
| 185 | + |
| 186 | + # We dont want to bother upstream with potentially outdated compat reports |
| 187 | + (lib.cmakeBool "YUZU_ENABLE_COMPATIBILITY_REPORTING" false) |
| 188 | + (lib.cmakeBool "ENABLE_COMPATIBILITY_LIST_DOWNLOAD" false) # We provide this deterministically |
| 189 | + ]; |
| 190 | + |
| 191 | + env = { |
| 192 | + # Does some handrolled SIMD |
| 193 | + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isx86_64 "-msse4.1"; |
| 194 | + }; |
| 195 | + |
| 196 | + qtWrapperArgs = [ |
| 197 | + # Fixes vulkan detection. |
| 198 | + # FIXME: patchelf --add-rpath corrupts the binary for some reason, investigate |
| 199 | + "--prefix LD_LIBRARY_PATH : ${vulkan-loader}/lib" |
| 200 | + ]; |
| 201 | + |
| 202 | + # Setting this through cmakeFlags does not work. |
| 203 | + # https://github.com/NixOS/nixpkgs/issues/114044 |
| 204 | + preConfigure = lib.concatStringsSep "\n" [ |
| 205 | + '' |
| 206 | + cmakeFlagsArray+=( |
| 207 | + "-DTITLE_BAR_FORMAT_IDLE=${finalAttrs.pname} | ${finalAttrs.version} (nixpkgs) {}" |
| 208 | + "-DTITLE_BAR_FORMAT_RUNNING=${finalAttrs.pname} | ${finalAttrs.version} (nixpkgs) | {}" |
| 209 | + ) |
| 210 | + '' |
| 211 | + # provide pre-downloaded tz data |
| 212 | + '' |
| 213 | + mkdir -p build/externals/nx_tzdb |
| 214 | + ln -s ${nx_tzdb} build/externals/nx_tzdb/nx_tzdb |
| 215 | + '' |
| 216 | + ]; |
| 217 | + |
| 218 | + postConfigure = '' |
| 219 | + ln -sf ${compat-list} ./dist/compatibility_list/compatibility_list.json |
| 220 | + ''; |
| 221 | + |
| 222 | + postInstall = " |
| 223 | + install -Dm444 $src/dist/72-yuzu-input.rules $out/lib/udev/rules.d/72-yuzu-input.rules |
| 224 | + "; |
| 225 | + |
| 226 | + meta = { |
| 227 | + description = "Fork of yuzu, an open-source Nintendo Switch emulator"; |
| 228 | + homepage = "https://notabug.org/litucks/torzu"; |
| 229 | + mainProgram = "yuzu"; |
| 230 | + platforms = lib.platforms.linux; |
| 231 | + badPlatforms = [ |
| 232 | + # Several conversion errors, probably caused by the update to GCC 14 |
| 233 | + "aarch64-linux" |
| 234 | + ]; |
| 235 | + maintainers = with lib.maintainers; [ liberodark ]; |
| 236 | + license = with lib.licenses; [ |
| 237 | + gpl3Plus |
| 238 | + # Icons |
| 239 | + asl20 |
| 240 | + mit |
| 241 | + cc0 |
| 242 | + ]; |
| 243 | + }; |
| 244 | +}) |
0 commit comments