|
| 1 | +{ |
| 2 | + lib, |
| 3 | + llvmPackages, |
| 4 | + fetchFromGitHub, |
| 5 | + cmake, |
| 6 | + pkg-config, |
| 7 | + ninja, |
| 8 | + extra-cmake-modules, |
| 9 | + wayland-scanner, |
| 10 | + makeBinaryWrapper, |
| 11 | + qt6, |
| 12 | + sdl3, |
| 13 | + zstd, |
| 14 | + libwebp, |
| 15 | + zlib, |
| 16 | + libpng, |
| 17 | + libjpeg, |
| 18 | + freetype, |
| 19 | + plutosvg, |
| 20 | + cpuinfo, |
| 21 | + discord-rpc, |
| 22 | + soundtouch, |
| 23 | + cubeb, |
| 24 | + libzip, |
| 25 | + curl, |
| 26 | + libX11, |
| 27 | + wayland, |
| 28 | + shaderc, |
| 29 | + spirv-cross, |
| 30 | + udev, |
| 31 | + libbacktrace, |
| 32 | + ffmpeg-headless, |
| 33 | + nix-update-script, |
| 34 | +}: |
| 35 | + |
| 36 | +llvmPackages.stdenv.mkDerivation (finalAttrs: { |
| 37 | + pname = "duckstation-unofficial"; |
| 38 | + version = "0.1-9384"; |
| 39 | + |
| 40 | + src = fetchFromGitHub { |
| 41 | + owner = "stenzek"; |
| 42 | + repo = "duckstation"; |
| 43 | + rev = "v${finalAttrs.version}"; |
| 44 | + hash = "sha256-Iwj+essyjgd5fo9lnNwaBc2N6UVfVlx3zHWlFS8MYqQ="; |
| 45 | + deepClone = true; |
| 46 | + |
| 47 | + postFetch = '' |
| 48 | + cd $out |
| 49 | + mkdir -p .nixpkgs-auxfiles/ |
| 50 | + git rev-parse HEAD > .nixpkgs-auxfiles/git_hash |
| 51 | + git rev-parse --abbrev-ref HEAD | tr -d '\r\n' > .nixpkgs-auxfiles/git_branch |
| 52 | + git describe --dirty | tr -d '\r\n' > .nixpkgs-auxfiles/git_tag |
| 53 | + git log -1 --date=iso8601-strict --format=%cd > .nixpkgs-auxfiles/git_date |
| 54 | + find $out -name .git -print0 | xargs -0 rm -fr |
| 55 | + ''; |
| 56 | + }; |
| 57 | + |
| 58 | + patches = [ |
| 59 | + # Patching yet another script that fills data based on git commands . . . |
| 60 | + ./hardcode-vars.patch |
| 61 | + # Fix NEON intrinsics usage |
| 62 | + ./fix-NEON-intrinsics.patch |
| 63 | + # un-vendor cubeb |
| 64 | + ./remove-cubeb-vendor.patch |
| 65 | + ]; |
| 66 | + |
| 67 | + postPatch = '' |
| 68 | + gitHash=$(cat .nixpkgs-auxfiles/git_hash) \ |
| 69 | + gitBranch=$(cat .nixpkgs-auxfiles/git_branch) \ |
| 70 | + gitTag=$(cat .nixpkgs-auxfiles/git_tag) \ |
| 71 | + gitDate=$(cat .nixpkgs-auxfiles/git_date) \ |
| 72 | + substituteAllInPlace src/scmversion/gen_scmversion.sh |
| 73 | + ''; |
| 74 | + |
| 75 | + vendorDiscordRPC = discord-rpc.overrideAttrs (oldAttrs: { |
| 76 | + pname = "discord-rpc-duckstation"; |
| 77 | + version = "3.4.0-unstable-2025-03-30"; |
| 78 | + src = fetchFromGitHub { |
| 79 | + owner = "stenzek"; |
| 80 | + repo = "discord-rpc"; |
| 81 | + rev = "cc59d26d1d628fbd6527aac0ac1d6301f4978b92"; |
| 82 | + hash = "sha256-8xXcx5w36eiJqtWm6qQfhEHgchVJbhP/jR94eMNNjHU="; |
| 83 | + }; |
| 84 | + patches = oldAttrs.patches or [ ]; |
| 85 | + }); |
| 86 | + |
| 87 | + vendorSoundtouch = soundtouch.overrideAttrs (oldAttrs: { |
| 88 | + pname = "soundtouch-duckstation"; |
| 89 | + version = "2.3.3-unstable-2025-10-01"; |
| 90 | + |
| 91 | + src = fetchFromGitHub { |
| 92 | + owner = "stenzek"; |
| 93 | + repo = "soundtouch"; |
| 94 | + rev = "b281fda49645c158c2085e1f2e0c3b82c84379ac"; |
| 95 | + hash = "sha256-RrGxZ2mJO4wi4kCgvATajd7rxqs2M8VRkZNow30kV+0="; |
| 96 | + }; |
| 97 | + |
| 98 | + nativeBuildInputs = [ cmake ]; |
| 99 | + |
| 100 | + preConfigure = null; |
| 101 | + }); |
| 102 | + |
| 103 | + vendorShaderc = shaderc.overrideAttrs (oldAttrs: { |
| 104 | + pname = "shaderc-duckstation"; |
| 105 | + version = "2025.2-unstable-2025-04-25"; |
| 106 | + src = fetchFromGitHub { |
| 107 | + owner = "stenzek"; |
| 108 | + repo = "shaderc"; |
| 109 | + rev = "4daf9d466ad00897f755163dd26f528d14e1db44"; |
| 110 | + hash = "sha256-/o3LPYvMTlKhuvLQITnADmz8BTGXVaVR0aciOWVyFS8="; |
| 111 | + }; |
| 112 | + |
| 113 | + patches = (oldAttrs.patches or [ ]); |
| 114 | + cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [ |
| 115 | + (lib.cmakeBool "SHADERC_SKIP_EXAMPLES" true) |
| 116 | + (lib.cmakeBool "SHADERC_SKIP_TESTS" true) |
| 117 | + ]; |
| 118 | + outputs = [ |
| 119 | + "out" |
| 120 | + "lib" |
| 121 | + "dev" |
| 122 | + ]; |
| 123 | + postFixup = null; |
| 124 | + }); |
| 125 | + |
| 126 | + vendorSpirvCross = spirv-cross.overrideAttrs (oldAttrs: { |
| 127 | + pname = "spirv-cross-duckstation"; |
| 128 | + patches = (oldAttrs.patches or [ ]); |
| 129 | + cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [ |
| 130 | + (lib.cmakeBool "SPIRV_CROSS_CLI" false) |
| 131 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_CPP" false) |
| 132 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_C_API" true) |
| 133 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_GLSL" true) |
| 134 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_HLSL" false) |
| 135 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_MSL" false) |
| 136 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_REFLECT" false) |
| 137 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_TESTS" false) |
| 138 | + (lib.cmakeBool "SPIRV_CROSS_ENABLE_UTIL" true) |
| 139 | + (lib.cmakeBool "SPIRV_CROSS_SHARED" true) |
| 140 | + (lib.cmakeBool "SPIRV_CROSS_STATIC" false) |
| 141 | + ]; |
| 142 | + }); |
| 143 | + |
| 144 | + nativeBuildInputs = [ |
| 145 | + cmake |
| 146 | + pkg-config |
| 147 | + ninja |
| 148 | + extra-cmake-modules |
| 149 | + wayland-scanner |
| 150 | + makeBinaryWrapper |
| 151 | + qt6.wrapQtAppsHook |
| 152 | + qt6.qttools |
| 153 | + ]; |
| 154 | + |
| 155 | + buildInputs = [ |
| 156 | + sdl3 |
| 157 | + zstd |
| 158 | + libwebp |
| 159 | + zlib |
| 160 | + libpng |
| 161 | + libjpeg |
| 162 | + freetype |
| 163 | + plutosvg |
| 164 | + cubeb |
| 165 | + cpuinfo |
| 166 | + libzip |
| 167 | + curl |
| 168 | + libX11 |
| 169 | + wayland |
| 170 | + qt6.qtbase |
| 171 | + udev |
| 172 | + libbacktrace |
| 173 | + ffmpeg-headless |
| 174 | + ] |
| 175 | + ++ [ |
| 176 | + finalAttrs.vendorDiscordRPC |
| 177 | + finalAttrs.vendorShaderc |
| 178 | + finalAttrs.vendorSoundtouch |
| 179 | + finalAttrs.vendorSpirvCross |
| 180 | + ]; |
| 181 | + |
| 182 | + cmakeFlags = [ |
| 183 | + (lib.cmakeBool "ALLOW_INSTALL" true) |
| 184 | + (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib/duckstation") |
| 185 | + ]; |
| 186 | + |
| 187 | + qtWrapperArgs = [ |
| 188 | + "--prefix LD_LIBRARY_PATH : ${(lib.makeLibraryPath [ ffmpeg-headless ])}" |
| 189 | + ]; |
| 190 | + |
| 191 | + postInstall = '' |
| 192 | + makeWrapper $out/lib/duckstation/duckstation-qt $out/bin/duckstation-qt |
| 193 | +
|
| 194 | + mkdir -p $out/share/applications/ |
| 195 | + ln -s $out/lib/duckstation/resources/org.duckstation.DuckStation.desktop \ |
| 196 | + $out/share/applications/ |
| 197 | +
|
| 198 | + mkdir -p $out/share/icons/hicolor/scalable/apps/ |
| 199 | + ln -s $out/lib/duckstation/resources/org.duckstation.DuckStation.png \ |
| 200 | + $out/share/icons/hicolor/scalable/apps/ |
| 201 | +
|
| 202 | + pushd .. |
| 203 | + install -Dm644 LICENSE -t $out/share/doc/duckstation |
| 204 | + install -Dm644 README.* -t $out/share/doc/duckstation |
| 205 | + install -Dm644 CONTRIBUTORS.md -t $out/share/doc/duckstation |
| 206 | + popd |
| 207 | + ''; |
| 208 | + |
| 209 | + passthru = { |
| 210 | + updateScript = nix-update-script { |
| 211 | + extraArgs = [ "--version-regex=(v[0-9].[0-9]-[0-9]+)" ]; |
| 212 | + }; |
| 213 | + }; |
| 214 | + |
| 215 | + meta = { |
| 216 | + description = "Fast PlayStation 1 emulator for x86-64/AArch32/AArch64/RV64"; |
| 217 | + longDescription = '' |
| 218 | + # DISCLAIMER |
| 219 | + This is an **unofficial** package, do not report any issues to |
| 220 | + duckstation developers. Instead, please report them to |
| 221 | + <https://github.com/NixOS/nixpkgs> or use the officially |
| 222 | + supported platform build at <https://duckstation.org> or other |
| 223 | + upstream-approved distribution mechanism not listed here. We |
| 224 | + (nixpkgs) do not endorse or condone any action taken on your own |
| 225 | + accord in regards to this package. |
| 226 | + ''; |
| 227 | + homepage = "https://duckstation.org/"; |
| 228 | + license = lib.licenses.cc-by-nc-nd-40; |
| 229 | + maintainers = with lib.maintainers; [ normalcea ]; |
| 230 | + mainProgram = "duckstation-qt"; |
| 231 | + platforms = lib.platforms.linux; |
| 232 | + }; |
| 233 | +}) |
0 commit comments