Skip to content

Commit ce6542e

Browse files
authored
sdl{2-compat,3}: clean up dependencies (#414472)
2 parents d24fd29 + 9149a3a commit ce6542e

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

pkgs/by-name/sd/sdl2-compat/package.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
ffmpeg,
2222
qemu,
2323
}:
24-
24+
let
25+
# tray support on sdl3 pulls in gtk3, which is quite an expensive dependency.
26+
# sdl2 does not support the tray, so we can just disable that requirement.
27+
sdl3' = sdl3.override { traySupport = false; };
28+
in
2529
stdenv.mkDerivation (finalAttrs: {
2630
pname = "sdl2-compat";
2731
version = "2.32.56";
@@ -39,7 +43,7 @@ stdenv.mkDerivation (finalAttrs: {
3943
];
4044

4145
buildInputs = [
42-
sdl3
46+
sdl3'
4347
libX11
4448
];
4549

@@ -57,7 +61,7 @@ stdenv.mkDerivation (finalAttrs: {
5761

5862
cmakeFlags = [
5963
(lib.cmakeBool "SDL2COMPAT_TESTS" finalAttrs.finalPackage.doCheck)
60-
(lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl3 ]))
64+
(lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl3' ]))
6165
];
6266

6367
# skip timing-based tests as those are flaky

pkgs/by-name/sd/sdl3/package.nix

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,29 @@
5151
libudevSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
5252
sndioSupport ? false,
5353
testSupport ? true,
54+
traySupport ? true,
5455
waylandSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
5556
x11Support ? !stdenv.hostPlatform.isAndroid && !stdenv.hostPlatform.isWindows,
5657
}:
5758

5859
assert lib.assertMsg (
5960
waylandSupport -> openglSupport
6061
) "SDL3 requires OpenGL support to enable Wayland";
62+
assert lib.assertMsg (ibusSupport -> dbusSupport) "SDL3 requires dbus support to enable ibus";
6163

6264
stdenv.mkDerivation (finalAttrs: {
6365
pname = "sdl3";
6466
version = "3.2.16";
6567

66-
outputs = [
67-
"lib"
68-
"dev"
69-
"out"
70-
];
68+
outputs =
69+
[
70+
"lib"
71+
"dev"
72+
"out"
73+
]
74+
++ lib.optionals testSupport [
75+
"installedTests"
76+
];
7177

7278
src = fetchFromGitHub {
7379
owner = "libsdl-org";
@@ -78,13 +84,19 @@ stdenv.mkDerivation (finalAttrs: {
7884

7985
postPatch =
8086
# Tests timeout on Darwin
87+
# `testtray` loads assets from a relative path, which we are patching to be absolute
8188
lib.optionalString testSupport ''
8289
substituteInPlace test/CMakeLists.txt \
8390
--replace-fail 'set(noninteractive_timeout 10)' 'set(noninteractive_timeout 30)'
91+
92+
substituteInPlace test/testtray.c \
93+
--replace-warn '../test/' '${placeholder "installedTests"}/share/assets/'
8494
''
8595
+ lib.optionalString waylandSupport ''
8696
substituteInPlace src/video/wayland/SDL_waylandmessagebox.c \
8797
--replace-fail '"zenity"' '"${lib.getExe zenity}"'
98+
substituteInPlace src/dialog/unix/SDL_zenitydialog.c \
99+
--replace-fail '"zenity"' '"${lib.getExe zenity}"'
88100
'';
89101

90102
strictDeps = true;
@@ -117,7 +129,7 @@ stdenv.mkDerivation (finalAttrs: {
117129
libusb1
118130
]
119131
++ lib.optional (
120-
stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isDarwin
132+
stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isDarwin && traySupport
121133
) libayatana-appindicator
122134
++ lib.optional alsaSupport alsa-lib
123135
++ lib.optional dbusSupport dbus
@@ -164,11 +176,13 @@ stdenv.mkDerivation (finalAttrs: {
164176
(lib.cmakeBool "SDL_PULSEAUDIO" pulseaudioSupport)
165177
(lib.cmakeBool "SDL_SNDIO" sndioSupport)
166178
(lib.cmakeBool "SDL_TEST_LIBRARY" testSupport)
179+
(lib.cmakeBool "SDL_TRAY_DUMMY" (!traySupport))
167180
(lib.cmakeBool "SDL_WAYLAND" waylandSupport)
168181
(lib.cmakeBool "SDL_WAYLAND_LIBDECOR" libdecorSupport)
169182
(lib.cmakeBool "SDL_X11" x11Support)
170183

171184
(lib.cmakeBool "SDL_TESTS" finalAttrs.finalPackage.doCheck)
185+
(lib.cmakeBool "SDL_INSTALL_TESTS" testSupport)
172186
];
173187

174188
doCheck = testSupport && stdenv.buildPlatform.canExecute stdenv.hostPlatform;
@@ -184,6 +198,12 @@ stdenv.mkDerivation (finalAttrs: {
184198
) "-rpath ${lib.makeLibraryPath (finalAttrs.dlopenBuildInputs)}";
185199
};
186200

201+
postInstall = lib.optionalString testSupport ''
202+
moveToOutput "share/installed-tests" "$installedTests"
203+
moveToOutput "libexec/installed-tests" "$installedTests"
204+
install -Dm 444 -t $installedTests/share/assets test/*.bmp
205+
'';
206+
187207
passthru = {
188208
# Building this in its own derivation to make sure the rpath hack above propagate to users
189209
debug-text-example = stdenv.mkDerivation (finalAttrs': {

0 commit comments

Comments
 (0)