1 { lib, stdenv, config, fetchurl, fetchpatch, pkg-config, audiofile, libcap, libiconv
2 , libGLSupported ? lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms
3 , openglSupport ? libGLSupported, libGL, libGLU
4 , alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsa-lib
5 , x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
6 , libXext, libICE, libXrandr
7 , pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid, libpulseaudio
8 , OpenGL, GLUT, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa
11 # NOTE: When editing this expression see if the same change applies to
17 extraPropagatedBuildInputs = [ ]
18 ++ optionals x11Support [ libXext libICE libXrandr ]
19 ++ optionals (openglSupport && stdenv.isLinux) [ libGL libGLU ]
20 ++ optionals (openglSupport && stdenv.isDarwin) [ OpenGL GLUT ]
21 ++ optional alsaSupport alsa-lib
22 ++ optional pulseaudioSupport libpulseaudio
23 ++ optional stdenv.isDarwin Cocoa;
24 rpath = makeLibraryPath extraPropagatedBuildInputs;
27 stdenv.mkDerivation rec {
32 url = "https://www.libsdl.org/release/${pname}-${version}.tar.gz";
33 sha256 = "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn";
36 # make: *** No rule to make target 'build/*.lo', needed by 'build/libSDL.la'. Stop.
37 postPatch = "patchShebangs ./configure";
39 outputs = [ "out" "dev" ];
40 outputBin = "dev"; # sdl-config
42 nativeBuildInputs = [ pkg-config ]
43 ++ optional stdenv.isLinux libcap;
45 propagatedBuildInputs = [ libiconv ] ++ extraPropagatedBuildInputs;
48 ++ optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile
49 ++ optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
53 "--disable-video-x11-xme"
55 # Building without this fails on Darwin with
57 # ./src/video/x11/SDL_x11sym.h:168:17: error: conflicting types for '_XData32'
58 # SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
60 # Please try revert the change that introduced this comment when updating SDL.
61 ] ++ optional stdenv.isDarwin "--disable-x11-shared"
62 ++ optional (!x11Support) "--without-x"
63 ++ optional alsaSupport "--with-alsa-prefix=${alsa-lib.out}/lib";
68 # Fix window resizing issues, e.g. for xmonad
69 # Ticket: http://bugzilla.libsdl.org/show_bug.cgi?id=1430
71 name = "fix_window_resizing.diff";
72 url = "https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=10;filename=fix_window_resizing.diff;att=2;bug=665779";
73 sha256 = "1z35azc73vvi19pzi6byck31132a8w1vzrghp1x3hy4a4f9z4gc6";
75 # Fix drops of keyboard events for SDL_EnableUNICODE
77 url = "https://github.com/libsdl-org/SDL-1.2/commit/0332e2bb18dc68d6892c3b653b2547afe323854b.patch";
78 sha256 = "0g458iv6pp9sikdch6ms8svz60lf5ks2q5wgid8s9rydhk98lpp5";
80 # Ignore insane joystick axis events
82 url = "https://github.com/libsdl-org/SDL-1.2/commit/ab99cc82b0a898ad528d46fa128b649a220a94f4.patch";
83 sha256 = "1b3473sawfdbkkxaqf1hg0vn37yk8hf655jhnjwdk296z4gclazh";
85 # https://bugzilla.libsdl.org/show_bug.cgi?id=1769
87 url = "https://github.com/libsdl-org/SDL-1.2/commit/5d79977ec7a6b58afa6e4817035aaaba186f7e9f.patch";
88 sha256 = "1k7y57b1zy5afib1g7w3in36n8cswbcrzdbrjpn5cb105rnb9vmp";
90 # Workaround X11 bug to allow changing gamma
91 # Ticket: https://bugs.freedesktop.org/show_bug.cgi?id=27222
93 name = "SDL_SetGamma.patch";
94 url = "https://src.fedoraproject.org/cgit/rpms/SDL.git/plain/SDL-1.2.15-x11-Bypass-SetGammaRamp-when-changing-gamma.patch?id=04a3a7b1bd88c2d5502292fad27e0e02d084698d";
95 sha256 = "0x52s4328kilyq43i7psqkqg7chsfwh0aawr50j566nzd7j51dlv";
97 # Fix a build failure on OS X Mavericks
98 # Ticket: https://bugzilla.libsdl.org/show_bug.cgi?id=2085
100 url = "https://github.com/libsdl-org/SDL-1.2/commit/19039324be71738d8990e91b9ba341b2ea068445.patch";
101 sha256 = "0ckwling2ad27c9vxgp97ndjd098d6zbrydza8b9l77k8airj98c";
104 url = "https://github.com/libsdl-org/SDL-1.2/commit/7933032ad4d57c24f2230db29f67eb7d21bb5654.patch";
105 sha256 = "1by16firaxyr0hjvn35whsgcmq6bl0nwhnpjf75grjzsw9qvwyia";
108 name = "CVE-2022-34568.patch";
109 url = "https://github.com/libsdl-org/SDL-1.2/commit/d7e00208738a0bc6af302723fe64908ac35b777b.patch";
110 sha256 = "sha256-fuxXsqZW94/C8CKu9LakppCU4zHupj66O2MngQ4BO9o=";
115 moveToOutput share/aclocal "$dev"
118 # See the same place in the expression for SDL2
120 for lib in $out/lib/*.so* ; do
121 if [[ -L "$lib" ]]; then
122 patchelf --set-rpath "$(patchelf --print-rpath $lib):${rpath}" "$lib"
127 setupHook = ./setup-hook.sh;
129 passthru = { inherit openglSupport; };
131 enableParallelBuilding = true;
134 description = "A cross-platform multimedia library";
135 homepage = "http://www.libsdl.org/";
136 maintainers = with maintainers; [ lovek323 ];
137 platforms = platforms.unix;
138 license = licenses.lgpl21;