Skip to content

Commit 81c3ed9

Browse files
committed
shadps4: refactor into emulator.nix
1 parent 78e802e commit 81c3ed9

File tree

2 files changed

+161
-170
lines changed

2 files changed

+161
-170
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
6+
nixosTests,
7+
alsa-lib,
8+
boost,
9+
cmake,
10+
cryptopp,
11+
glslang,
12+
ffmpeg,
13+
fmt,
14+
half,
15+
jack2,
16+
libdecor,
17+
libpulseaudio,
18+
libunwind,
19+
libusb1,
20+
magic-enum,
21+
libgbm,
22+
libx11,
23+
libxcb,
24+
libxcursor,
25+
libxext,
26+
libxi,
27+
libxrandr,
28+
libxscrnsaver,
29+
libxtst,
30+
pipewire,
31+
pkg-config,
32+
pugixml,
33+
rapidjson,
34+
renderdoc,
35+
robin-map,
36+
sndio,
37+
stb,
38+
toml11,
39+
util-linux,
40+
vulkan-headers,
41+
vulkan-loader,
42+
vulkan-memory-allocator,
43+
xbyak,
44+
xxHash,
45+
zlib-ng,
46+
zydis,
47+
nix-update-script,
48+
}:
49+
50+
stdenv.mkDerivation (finalAttrs: {
51+
pname = "shadps4";
52+
version = "0.13.0";
53+
54+
src = fetchFromGitHub {
55+
owner = "shadps4-emu";
56+
repo = "shadPS4";
57+
tag = "v.${finalAttrs.version}";
58+
hash = "sha256-kHob03/ywR30AFXKuySf54yEuiYMoAb68QRtekomXH0=";
59+
fetchSubmodules = true;
60+
61+
leaveDotGit = true;
62+
postFetch = ''
63+
cd "$out"
64+
git rev-parse HEAD > $out/COMMIT
65+
date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH
66+
find "$out" -name .git -print0 | xargs -0 rm -rf
67+
'';
68+
};
69+
70+
postPatch = ''
71+
substituteInPlace src/common/scm_rev.cpp.in \
72+
--replace-fail @APP_VERSION@ ${finalAttrs.version} \
73+
--replace-fail @GIT_REV@ $(cat COMMIT) \
74+
--replace-fail @GIT_BRANCH@ ${finalAttrs.version} \
75+
--replace-fail @GIT_DESC@ ${finalAttrs.version} \
76+
--replace-fail @BUILD_DATE@ $(cat SOURCE_DATE_EPOCH)
77+
'';
78+
79+
buildInputs = [
80+
alsa-lib
81+
boost
82+
cryptopp
83+
glslang
84+
ffmpeg
85+
fmt
86+
half
87+
jack2
88+
libdecor
89+
libpulseaudio
90+
libunwind
91+
libusb1
92+
libx11
93+
libxcb
94+
libxcursor
95+
libxext
96+
libxi
97+
libxrandr
98+
libxscrnsaver
99+
libxtst
100+
magic-enum
101+
libgbm
102+
pipewire
103+
pugixml
104+
rapidjson
105+
renderdoc
106+
robin-map
107+
sndio
108+
stb
109+
toml11
110+
util-linux
111+
vulkan-headers
112+
vulkan-loader
113+
vulkan-memory-allocator
114+
xbyak
115+
xxHash
116+
zlib-ng
117+
zydis
118+
];
119+
120+
nativeBuildInputs = [
121+
cmake
122+
pkg-config
123+
];
124+
125+
cmakeFlags = [
126+
(lib.cmakeBool "ENABLE_UPDATER" false)
127+
];
128+
129+
# Still in development, help with debugging
130+
cmakeBuildType = "RelWithDebugInfo";
131+
dontStrip = true;
132+
133+
installPhase = ''
134+
runHook preInstall
135+
136+
install -D -t $out/bin shadps4
137+
install -Dm644 $src/.github/shadps4.png $out/share/icons/hicolor/512x512/apps/net.shadps4.shadPS4.png
138+
install -Dm644 -t $out/share/applications $src/dist/net.shadps4.shadPS4.desktop
139+
install -Dm644 -t $out/share/metainfo $src/dist/net.shadps4.shadPS4.metainfo.xml
140+
141+
runHook postInstall
142+
'';
143+
144+
runtimeDependencies = [
145+
vulkan-loader
146+
libxi
147+
];
148+
149+
passthru = {
150+
tests.openorbis-example = nixosTests.shadps4;
151+
updateScript = nix-update-script {
152+
extraArgs = [
153+
"--version-regex"
154+
"v\\.(.*)"
155+
];
156+
};
157+
};
158+
})
Lines changed: 3 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,9 @@
11
{
22
lib,
3-
stdenv,
4-
fetchFromGitHub,
5-
6-
nixosTests,
7-
alsa-lib,
8-
boost,
9-
cmake,
10-
cryptopp,
11-
game-music-emu,
12-
glslang,
13-
ffmpeg,
14-
flac,
15-
fluidsynth,
16-
fmt,
17-
half,
18-
jack2,
19-
libdecor,
20-
libGL,
21-
libpulseaudio,
22-
libunwind,
23-
libusb1,
24-
libvorbis,
25-
libxmp,
26-
libgbm,
27-
libx11,
28-
libxcb,
29-
libxcursor,
30-
libxext,
31-
libxi,
32-
libxrandr,
33-
libxscrnsaver,
34-
libxtst,
35-
magic-enum,
36-
mpg123,
37-
pipewire,
38-
pkg-config,
39-
pugixml,
40-
rapidjson,
41-
renderdoc,
42-
robin-map,
43-
sndio,
44-
stb,
45-
toml11,
46-
util-linux,
47-
vulkan-headers,
48-
vulkan-loader,
49-
vulkan-memory-allocator,
50-
xbyak,
51-
xxHash,
52-
zlib-ng,
53-
zydis,
54-
nix-update-script,
3+
callPackage,
554
}:
565

57-
stdenv.mkDerivation (finalAttrs: {
58-
pname = "shadps4";
59-
version = "0.13.0";
60-
61-
src = fetchFromGitHub {
62-
owner = "shadps4-emu";
63-
repo = "shadPS4";
64-
tag = "v.${finalAttrs.version}";
65-
hash = "sha256-yRQMk9STf9/bykWauoZVh6CY95A0VfgC5xuHi8a87g4=";
66-
fetchSubmodules = true;
67-
68-
leaveDotGit = true;
69-
postFetch = ''
70-
cd "$out"
71-
git rev-parse --abbrev-ref HEAD > $out/BRANCH
72-
git rev-parse --short HEAD > $out/COMMIT
73-
date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH
74-
find "$out" -name .git -print0 | xargs -0 rm -rf
75-
'';
76-
};
77-
78-
postPatch = ''
79-
substituteInPlace src/common/scm_rev.cpp.in \
80-
--replace-fail @APP_VERSION@ ${finalAttrs.version} \
81-
--replace-fail @GIT_REV@ $(cat COMMIT) \
82-
--replace-fail @GIT_BRANCH@ $(cat BRANCH) \
83-
--replace-fail @GIT_DESC@ $(cat COMMIT) \
84-
--replace-fail @BUILD_DATE@ $(cat SOURCE_DATE_EPOCH)
85-
'';
86-
87-
buildInputs = [
88-
alsa-lib
89-
boost
90-
cryptopp
91-
game-music-emu
92-
glslang
93-
ffmpeg
94-
flac
95-
fluidsynth
96-
fmt
97-
half
98-
jack2
99-
libdecor
100-
libGL
101-
libpulseaudio
102-
libunwind
103-
libusb1
104-
libvorbis
105-
libxmp
106-
libx11
107-
libxcb
108-
libxcursor
109-
libxext
110-
libxi
111-
libxrandr
112-
libxscrnsaver
113-
libxtst
114-
libgbm
115-
magic-enum
116-
mpg123
117-
pipewire
118-
pugixml
119-
rapidjson
120-
renderdoc
121-
robin-map
122-
sndio
123-
stb
124-
toml11
125-
util-linux
126-
vulkan-headers
127-
vulkan-loader
128-
vulkan-memory-allocator
129-
xbyak
130-
xxHash
131-
zlib-ng
132-
zydis
133-
];
134-
135-
nativeBuildInputs = [
136-
cmake
137-
pkg-config
138-
];
139-
140-
cmakeFlags = [
141-
(lib.cmakeBool "ENABLE_UPDATER" false)
142-
];
143-
144-
# Still in development, help with debugging
145-
cmakeBuildType = "RelWithDebugInfo";
146-
dontStrip = true;
147-
148-
installPhase = ''
149-
runHook preInstall
150-
151-
install -D -t $out/bin shadps4
152-
install -Dm644 $src/.github/shadps4.png $out/share/icons/hicolor/512x512/apps/net.shadps4.shadPS4.png
153-
install -Dm644 -t $out/share/applications $src/dist/net.shadps4.shadPS4.desktop
154-
install -Dm644 -t $out/share/metainfo $src/dist/net.shadps4.shadPS4.metainfo.xml
155-
156-
runHook postInstall
157-
'';
158-
159-
runtimeDependencies = [
160-
vulkan-loader
161-
libxi
162-
];
163-
164-
passthru = {
165-
tests.openorbis-example = nixosTests.shadps4;
166-
updateScript = nix-update-script {
167-
extraArgs = [
168-
"--version-regex"
169-
"v\\.(.*)"
170-
];
171-
};
172-
};
173-
6+
callPackage ./emulator.nix { } // {
1747
meta = {
1758
description = "Early in development PS4 emulator";
1769
homepage = "https://github.com/shadps4-emu/shadPS4";
@@ -182,4 +15,4 @@ stdenv.mkDerivation (finalAttrs: {
18215
mainProgram = "shadps4";
18316
platforms = lib.intersectLists lib.platforms.linux lib.platforms.x86_64;
18417
};
185-
})
18+
}

0 commit comments

Comments
 (0)