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
5859assert 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
6264stdenv . 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