nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 SDL,
4 fetchpatch,
5 fetchurl,
6 fluidsynth,
7 libopenmpt-modplug,
8 libogg,
9 libvorbis,
10 pkg-config,
11 smpeg,
12 stdenv,
13 # passthru.tests
14 onscripter-en,
15 # Boolean flags
16 enableNativeMidi ? false,
17 enableSdltest ? (!stdenv.hostPlatform.isDarwin),
18 enableSmpegtest ? (!stdenv.hostPlatform.isDarwin),
19}:
20
21stdenv.mkDerivation (finalAttrs: {
22 pname = "SDL_mixer";
23 version = "1.2.12";
24
25 # word of caution: while there is a somewhat maintained SDL-1.2 branch on
26 # https://github.com/libsdl-org/SDL_mixer, it switches from smpeg to mpg123 which
27 # breaks autoconf in a bunch of packages, it's better to cherry-pick patches as needed
28 src = fetchurl {
29 url = "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-${finalAttrs.version}.tar.gz";
30 hash = "sha256-FkQwgnmpdXmQSeSCavLPx4fK0quxGqFFYuQCUh+GmSo=";
31 };
32
33 patches = [
34 # Fixes implicit declaration of `Mix_QuitFluidSynth`, which causes build failures with clang.
35 # https://github.com/libsdl-org/SDL_mixer/issues/287
36 (fetchpatch {
37 name = "fluidsynth-fix-implicit-declaration.patch";
38 url = "https://github.com/libsdl-org/SDL_mixer/commit/05b12a3c22c0746c29dc5478f5b7fbd8a51a1303.patch";
39 hash = "sha256-MDuViLD1w1tAVLoX2yFeJ865v21S2roi0x7Yi7GYRVU=";
40 })
41 # Backport of 2.0 fixes for incompatible function pointer conversions, fixing builds with clang.
42 (fetchpatch {
43 name = "fluidsynth-fix-function-pointer-conversions.patch";
44 url = "https://github.com/libsdl-org/SDL_mixer/commit/0c504159d212b710a47cb25c669b21730fc78edd.patch";
45 hash = "sha256-FSj7JLE2MbGVYCspoq3trXP5Ho+lAtnro2IUOHkto/U";
46 })
47 # Backport of MikMod fixes, which includes incompatible function pointer conversions.
48 (fetchpatch {
49 name = "mikmod-fixes.patch";
50 url = "https://github.com/libsdl-org/SDL_mixer/commit/a3e5ff8142cf3530cddcb27b58f871f387796ab6.patch";
51 hash = "sha256-dqD8hxx6U2HaelUx0WsGPiWuso++LjwasaAeTTGqdbk=";
52 })
53 # More incompatible function pointer conversion fixes (this time in Vorbis-decoding code).
54 (fetchpatch {
55 name = "vorbis-fix-function-pointer-conversion.patch";
56 url = "https://github.com/libsdl-org/SDL_mixer/commit/9e6d7b67a00656a68ea0c2eace75c587871549b9.patch";
57 hash = "sha256-rZI3bFb/KxnduTkA/9CISccKHUgrX22KXg69sl/uXvU=";
58 })
59 (fetchpatch {
60 name = "vorbis-fix-function-pointer-conversion-header-part.patch";
61 url = "https://github.com/libsdl-org/SDL_mixer/commit/03bd4ca6aa38c1a382c892cef86296cd621ecc1d.patch";
62 hash = "sha256-7HrSHYFYVgpamP7Q9znrFZMZ72jvz5wYpJEPqWev/I4=";
63 })
64 (fetchpatch {
65 name = "vorbis-fix-function-pointer-signature.patch";
66 url = "https://github.com/libsdl-org/SDL_mixer/commit/d28cbc34d63dd20b256103c3fe506ecf3d34d379.patch";
67 hash = "sha256-sGbtF+Tcjf+6a28nJgawefeeKXnhcwu7G55e94oS9AU=";
68 })
69 ];
70
71 # Fix location of modplug header
72 postPatch = ''
73 substituteInPlace music_modplug.h \
74 --replace-fail '#include "modplug.h"' '#include <libmodplug/modplug.h>'
75 '';
76
77 nativeBuildInputs = [
78 pkg-config
79 ];
80
81 buildInputs = [
82 SDL
83 fluidsynth
84 libopenmpt-modplug
85 libogg
86 libvorbis
87 smpeg
88 ];
89
90 # pass in correct *-config for cross builds
91 env.SDL_CONFIG = lib.getExe' (lib.getDev SDL) "sdl-config";
92 env.SMPEG_CONFIG = lib.getExe' smpeg.dev "smpeg-config";
93
94 configureFlags = [
95 (lib.enableFeature false "music-ogg-shared")
96 (lib.enableFeature false "music-mod-shared")
97 (lib.enableFeature true "music-mod-modplug")
98 (lib.enableFeature enableNativeMidi "music-native-midi-gpl")
99 (lib.enableFeature enableSdltest "sdltest")
100 (lib.enableFeature enableSmpegtest "smpegtest")
101 ];
102
103 outputs = [
104 "out"
105 "dev"
106 ];
107
108 strictDeps = true;
109
110 passthru.tests = {
111 inherit onscripter-en;
112 };
113
114 meta = {
115 description = "SDL multi-channel audio mixer library";
116 homepage = "http://www.libsdl.org/projects/SDL_mixer/";
117 teams = [ lib.teams.sdl ];
118 license = lib.licenses.zlib;
119 inherit (SDL.meta) platforms;
120 };
121})