15 libayatana-appindicator,
37 alsaSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
38 dbusSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
39 drmSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
40 ibusSupport ? stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isDarwin,
41 jackSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
42 libdecorSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
43 openglSupport ? lib.meta.availableOn stdenv.hostPlatform libGL,
44 pipewireSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
46 config.pulseaudio or stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
47 libudevSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
50 waylandSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid,
51 x11Support ? !stdenv.hostPlatform.isAndroid && !stdenv.hostPlatform.isWindows,
54 stdenv.mkDerivation (finalAttrs: {
64 src = fetchFromGitHub {
67 tag = "release-${finalAttrs.version}";
68 hash = "sha256-AbEwpIxgYl3g4calnWca8Vz/Tw1DnYfZrD1Vl5cSMpk=";
72 # Tests timeout on Darwin
73 lib.optionalString testSupport ''
74 substituteInPlace test/CMakeLists.txt \
75 --replace-fail 'set(noninteractive_timeout 10)' 'set(noninteractive_timeout 30)'
77 + lib.optionalString waylandSupport ''
78 substituteInPlace src/video/wayland/SDL_waylandmessagebox.c \
79 --replace-fail '"zenity"' '"${lib.getExe zenity}"'
88 ] ++ lib.optional waylandSupport wayland-scanner;
91 finalAttrs.dlopenBuildInputs
92 ++ lib.optionals stdenv.hostPlatform.isDarwin [
93 # error: 'MTLPixelFormatASTC_4x4_LDR' is unavailable: not available on macOS
94 (darwinMinVersionHook "11.0")
98 ++ lib.optionals ibusSupport [
102 ++ lib.optional waylandSupport zenity;
105 lib.optionals stdenv.hostPlatform.isLinux [
109 stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isDarwin
110 ) libayatana-appindicator
111 ++ lib.optional alsaSupport alsa-lib
112 ++ lib.optional dbusSupport dbus
113 ++ lib.optionals drmSupport [
117 ++ lib.optional jackSupport libjack2
118 ++ lib.optional libdecorSupport libdecor
119 ++ lib.optional libudevSupport systemdLibs
120 ++ lib.optional openglSupport libGL
121 ++ lib.optional pipewireSupport pipewire
122 ++ lib.optional pulseaudioSupport libpulseaudio
123 ++ lib.optional sndioSupport sndio
124 ++ lib.optionals waylandSupport [
128 ++ lib.optionals x11Support [
138 propagatedBuildInputs = finalAttrs.dlopenPropagatedBuildInputs;
140 dlopenPropagatedBuildInputs =
145 ++ lib.optional (openglSupport && !stdenv.hostPlatform.isDarwin) libGL
146 ++ lib.optional x11Support xorg.libX11;
149 (lib.cmakeBool "SDL_ALSA" alsaSupport)
150 (lib.cmakeBool "SDL_DBUS" dbusSupport)
151 (lib.cmakeBool "SDL_IBUS" ibusSupport)
152 (lib.cmakeBool "SDL_JACK" jackSupport)
153 (lib.cmakeBool "SDL_KMSDRM" drmSupport)
154 (lib.cmakeBool "SDL_LIBUDEV" libudevSupport)
155 (lib.cmakeBool "SDL_OPENGL" openglSupport)
156 (lib.cmakeBool "SDL_PIPEWIRE" pipewireSupport)
157 (lib.cmakeBool "SDL_PULSEAUDIO" pulseaudioSupport)
158 (lib.cmakeBool "SDL_SNDIO" sndioSupport)
159 (lib.cmakeBool "SDL_TEST_LIBRARY" testSupport)
160 (lib.cmakeBool "SDL_WAYLAND" waylandSupport)
161 (lib.cmakeBool "SDL_WAYLAND_LIBDECOR" libdecorSupport)
162 (lib.cmakeBool "SDL_X11" x11Support)
164 (lib.cmakeBool "SDL_TESTS" finalAttrs.finalPackage.doCheck)
167 doCheck = testSupport && stdenv.buildPlatform.canExecute stdenv.hostPlatform;
169 # See comment below. We actually *do* need these RPATH entries
173 # Many dependencies are not directly linked to, but dlopen()'d at runtime. Adding them to the RPATH
174 # helps them be found
176 lib.optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so")
178 lib.makeLibraryPath (finalAttrs.dlopenBuildInputs ++ finalAttrs.dlopenPropagatedBuildInputs)
183 # Building this in its own derivation to make sure the rpath hack above propagate to users
184 debug-text-example = stdenv.mkDerivation (finalAttrs': {
185 pname = "sdl3-debug-text-example";
186 inherit (finalAttrs) version src;
188 sourceRoot = "${finalAttrs'.src.name}/examples/renderer/18-debug-text";
190 nativeBuildInputs = [
194 buildInputs = [ finalAttrs.finalPackage ];
197 $CC -lSDL3 -o debug-text{,.c}
201 installBin debug-text
205 inherit (finalAttrs.meta) maintainers platforms;
206 mainProgram = "debug-text";
212 pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
213 inherit (finalAttrs.passthru) debug-text-example;
215 // lib.optionalAttrs stdenv.hostPlatform.isLinux {
216 nixosTest = nixosTests.sdl3;
219 updateScript = nix-update-script {
228 description = "Cross-platform development library";
229 homepage = "https://libsdl.org";
230 changelog = "https://github.com/libsdl-org/SDL/releases/tag/${finalAttrs.src.tag}";
231 license = lib.licenses.zlib;
232 maintainers = with lib.maintainers; [ getchoo ];
233 platforms = lib.platforms.unix;
234 pkgConfigModules = [ "sdl3" ];