1{
2 lib,
3 fetchFromGitHub,
4 sdl3,
5 cmake,
6 cubeb,
7 curl,
8 extra-cmake-modules,
9 ffmpeg,
10 gtk3,
11 libXrandr,
12 libaio,
13 libbacktrace,
14 libpcap,
15 libwebp,
16 llvmPackages,
17 lz4,
18 pkg-config,
19 qt6,
20 shaderc,
21 soundtouch,
22 strip-nondeterminism,
23 vulkan-headers,
24 vulkan-loader,
25 wayland,
26 wrapGAppsHook3,
27 zip,
28 zstd,
29 plutovg,
30 plutosvg,
31 kddockwidgets,
32}:
33
34let
35 pcsx2_patches = fetchFromGitHub {
36 owner = "PCSX2";
37 repo = "pcsx2_patches";
38 rev = "9b193aa0a61f5e93d3bd4124b111e8f296ef9fa8";
39 hash = "sha256-1hhdjFxJCNfeO/FIAnjRHESfiyzkErYddZqpRxzG7VQ=";
40 };
41
42 inherit (qt6)
43 qtbase
44 qtsvg
45 qttools
46 qtwayland
47 wrapQtAppsHook
48 ;
49in
50llvmPackages.stdenv.mkDerivation (finalAttrs: {
51 pname = "pcsx2";
52 version = "2.4.0";
53 src = fetchFromGitHub {
54 pname = "pcsx2-source";
55 owner = "PCSX2";
56 repo = "pcsx2";
57 tag = "v${finalAttrs.version}";
58 hash = "sha256-R+BdywkZKxR/+Z+o1512O3A1mg9A6s7i+JZjFyUbJVs=";
59 };
60
61 patches = [
62 # Remove PCSX2_GIT_REV
63 ./0000-define-rev.patch
64
65 ./remove-cubeb-vendor.patch
66 ];
67
68 cmakeFlags = [
69 (lib.cmakeBool "PACKAGE_MODE" true)
70 (lib.cmakeBool "DISABLE_ADVANCE_SIMD" true)
71 (lib.cmakeBool "USE_LINKED_FFMPEG" true)
72 (lib.cmakeFeature "PCSX2_GIT_REV" finalAttrs.src.tag)
73 ];
74
75 nativeBuildInputs = [
76 cmake
77 extra-cmake-modules
78 pkg-config
79 strip-nondeterminism
80 wrapGAppsHook3
81 wrapQtAppsHook
82 zip
83 ];
84
85 buildInputs = [
86 curl
87 ffmpeg
88 gtk3
89 libaio
90 libbacktrace
91 libpcap
92 libwebp
93 libXrandr
94 lz4
95 qtbase
96 qtsvg
97 qttools
98 qtwayland
99 sdl3
100 plutovg
101 plutosvg
102 kddockwidgets
103 shaderc
104 soundtouch
105 vulkan-headers
106 wayland
107 zstd
108 cubeb
109 ];
110
111 strictDeps = true;
112
113 postInstall = ''
114 install -Dm644 $src/pcsx2-qt/resources/icons/AppIcon64.png $out/share/pixmaps/PCSX2.png
115 install -Dm644 $src/.github/workflows/scripts/linux/pcsx2-qt.desktop $out/share/applications/PCSX2.desktop
116
117 zip -jq $out/share/PCSX2/resources/patches.zip ${pcsx2_patches}/patches/*
118 strip-nondeterminism $out/share/PCSX2/resources/patches.zip
119 '';
120
121 qtWrapperArgs =
122 let
123 libs = lib.makeLibraryPath ([
124 vulkan-loader
125 shaderc
126 ]);
127 in
128 [ "--prefix LD_LIBRARY_PATH : ${libs}" ];
129
130 dontWrapGApps = true;
131
132 preFixup = ''
133 qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
134 '';
135
136 passthru = {
137 inherit pcsx2_patches;
138 updateScript.command = [ ./update.sh ];
139 };
140
141 meta = {
142 homepage = "https://pcsx2.net";
143 description = "Playstation 2 emulator";
144 longDescription = ''
145 PCSX2 is an open-source PlayStation 2 (AKA PS2) emulator. Its purpose is
146 to emulate the PS2 hardware, using a combination of MIPS CPU Interpreters,
147 Recompilers and a Virtual Machine which manages hardware states and PS2
148 system memory. This allows you to play PS2 games on your PC, with many
149 additional features and benefits.
150 '';
151 changelog = "https://github.com/PCSX2/pcsx2/releases/tag/v${finalAttrs.version}";
152 downloadPage = "https://github.com/PCSX2/pcsx2";
153 license = with lib.licenses; [
154 gpl3Plus
155 lgpl3Plus
156 ];
157 mainProgram = "pcsx2-qt";
158 maintainers = with lib.maintainers; [
159 _0david0mp
160 hrdinka
161 govanify
162 matteopacini
163 ];
164 platforms = lib.systems.inspect.patternLogicalAnd lib.systems.inspect.patterns.isLinux lib.systems.inspect.patterns.isx86_64;
165 };
166})