-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathflake.nix
More file actions
237 lines (220 loc) · 6.63 KB
/
Copy pathflake.nix
File metadata and controls
237 lines (220 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
## SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
## SPDX-License-Identifier: GPL-2.0-or-later
{
description = "shadPS4 Nix Flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
pkgsLinux = nixpkgs.legacyPackages.x86_64-linux;
in
{
formatter.x86_64-linux = pkgsLinux.nixpkgs-fmt;
devShells.x86_64-linux.default =
let
shell =
{ self
, lib
, mkShell
, clangStdenv
, clang-tools
, cmake
, pkg-config
, vulkan-loader
, mesa
, renderdoc
, gef
, strace
, perf
, sdl3
, vulkan-tools
, libGL
, jack1
, fribidi
, libthai
, libpulseaudio
, sndio
, libdrm
, libgbm
, libusb1
, libxkbcommon
, libxcursor
, libxext
, libxfixes
, libxi
, libxinerama
, libxrandr
, libxrender
, libxtst
, libX11
, libxcb
, libxscrnsaver
, enableDebugTooling ? true
,
}:
let
runtimeDeps = [
libGL
libxext
libdrm
libgbm
libpulseaudio
];
# SDL3 requres extra libraries inside the devshell in order to pass CMake's configure.
sdlConfigureDeps = [
jack1
fribidi
libthai
sndio
libusb1
libxkbcommon
libxcursor
libxfixes
libxi
libxinerama
libxrandr
libxrender
libxtst
libxscrnsaver
] ++ runtimeDeps;
in
mkShell.override { stdenv = clangStdenv; } {
inputsFrom = [ self.packages.x86_64-linux.default ];
packages = [
clang-tools
cmake
pkg-config
libxcb.dev
] ++ sdlConfigureDeps ++ lib.optionals enableDebugTooling [ renderdoc gef strace perf vulkan-tools ];
shellHook = ''
echo "Entering shadPS4 development shell!"
export LD_LIBRARY_PATH="${lib.makeLibraryPath (lib.flatten runtimeDeps ++ [ vulkan-loader libX11 ])}:$LD_LIBRARY_PATH"
'';
CMAKE_C_COMPILER = "clang";
CMAKE_CXX_COMPILER = "clang++";
CMAKE_EXPORT_COMPILE_COMMANDS = "ON";
};
in
pkgsLinux.callPackage shell { inherit self; };
packages.x86_64-linux =
let
buildSettings = {
"release" = { symbols = false; flag = "-DCMAKE_BUILD_TYPE=Release"; };
"relWithDebInfo" = { symbols = true; flag = "-DCMAKE_BUILD_TYPE=RelWithDebInfo"; };
"debug" = { symbols = true; flag = "-DCMAKE_BUILD_TYPE=Debug"; };
};
getBuildSettings = chosenBuild: buildSettings.${chosenBuild} or (abort "Build mode not valid! Use \"debug\", \"release\", or \"relWithDebInfo\".");
build =
{ clangStdenv
, lib
, cmake
, ninja
, pkg-config
, libX11
, libxrandr
, libxext
, libxcursor
, libxi
, libxscrnsaver
, libxtst
, libxcb
, boost
, cli11
, ffmpeg
, fmt
, freetype
, glslang
, magic-enum
, miniupnpc
, miniz
, nlohmann_json
, libpng
, openal
, libressl
, renderdoc
, sdl3
, stb
, toml11
, robin-map
, vulkan-headers
, vulkan-memory-allocator
, xbyak
, xxhash
, zlib
, zydis
, pugixml
, libuuid
, systemdMinimal
, libx11
, releaseMode ? "debug"
, enableDiscordRpc ? false
,
}:
clangStdenv.mkDerivation (finalAttrs: {
name = "${finalAttrs.pname}-${finalAttrs.version}-${finalAttrs.system}";
pname = "shadps4";
version = "0.18.1";
system = "x86_64-linux";
src = ./.;
nativeBuildInputs = [
cmake
ninja
pkg-config
];
buildInputs = [
boost
cli11
ffmpeg
fmt
freetype
glslang
magic-enum
miniupnpc
miniz
nlohmann_json
libpng
openal
libressl
renderdoc
sdl3
stb
toml11
robin-map
vulkan-headers
vulkan-memory-allocator
xbyak
xxhash
zlib
zydis
pugixml
libuuid
systemdMinimal
libx11
];
cmakeFlags = [
(getBuildSettings releaseMode).flag
(lib.cmakeBool "ENABLE_DISCORD_RPC" enableDiscordRpc)
(lib.cmakeBool "ENABLE_TESTS" false)
(lib.cmakeBool "ENABLE_SYSTEM_LIBRARIES" true)
];
dontStrip = (getBuildSettings releaseMode).symbols;
# Cannot get the Branch name from the sandbox.
# Getting the commit hash can still be acquired through self.
patchPhase = ''
substituteInPlace src/common/scm_rev.cpp.in \
--replace-fail "@GIT_BRANCH@" "${self.shortRev or "Dirty"}"
substituteInPlace src/common/scm_rev.cpp.in \
--replace-fail "@GIT_DESC@" ""
'';
});
in
{
debug = pkgsLinux.callPackage build { releaseMode = "debug"; };
release = pkgsLinux.callPackage build { releaseMode = "release"; };
releaseWithDebInfo = pkgsLinux.callPackage build { releaseMode = "relWithDebInfo"; };
default = pkgsLinux.callPackage build { releaseMode = "relWithDebInfo"; };
};
};
}