nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 alsa-lib,
4 cmake,
5 enet,
6 fetchFromGitHub,
7 fetchpatch2,
8 fixDarwinDylibNames,
9 flac,
10 freetype,
11 gitUpdater,
12 gtk3,
13 libGL,
14 libGLU,
15 libjpeg,
16 libpng,
17 libpthreadstubs,
18 libpulseaudio,
19 libtheora,
20 libvorbis,
21 libwebp,
22 libX11,
23 libXcursor,
24 libXdmcp,
25 libXext,
26 libXfixes,
27 libXi,
28 libXpm,
29 libXt,
30 libXxf86dga,
31 libXxf86misc,
32 libXxf86vm,
33 openal,
34 physfs,
35 pkg-config,
36 stdenv,
37 texinfo,
38 xorgproto,
39 zlib,
40 # https://github.com/liballeg/allegro5/blob/master/README_sdl.txt
41 useSDL ? false,
42 sdl2-compat ? null,
43}:
44
45assert useSDL -> sdl2-compat != null;
46
47stdenv.mkDerivation rec {
48 pname = "allegro";
49 version = "5.2.10.1";
50
51 src = fetchFromGitHub {
52 owner = "liballeg";
53 repo = "allegro5";
54 rev = version;
55 sha256 = "sha256-agE3K+6VhhG/LO52fiesCsOq1fNYVRhdW7aKdPCbTOo=";
56 };
57
58 patches = [
59 (fetchpatch2 {
60 name = "Bump-CMake-minimum-version-to-3.5";
61 url = "https://github.com/liballeg/allegro5/commit/6e93fcaabaafd81701f4cd1b74f4b69dd598bc9b.patch?full_index=1";
62 hash = "sha256-IEnn66bS2m6MVFCNf341yLtd7jTl2gflL5EFJFmbEt4=";
63 })
64 ];
65
66 nativeBuildInputs = [
67 cmake
68 pkg-config
69 ]
70 ++ lib.optionals stdenv.hostPlatform.isDarwin [
71 fixDarwinDylibNames
72 ];
73
74 buildInputs = [
75 enet
76 flac
77 freetype
78 gtk3
79 libGL
80 libGLU
81 libjpeg
82 libpng
83 libtheora
84 libvorbis
85 libwebp
86 openal
87 physfs
88 texinfo
89 zlib
90 ]
91 ++ lib.optionals stdenv.hostPlatform.isLinux [
92 alsa-lib
93 libpthreadstubs
94 libpulseaudio
95 libX11
96 libXcursor
97 libXdmcp
98 libXext
99 libXfixes
100 libXi
101 libXpm
102 libXt
103 libXxf86dga
104 libXxf86misc
105 libXxf86vm
106 xorgproto
107 ]
108 ++ lib.optionals useSDL [
109 sdl2-compat
110 ];
111
112 postPatch = ''
113 sed -e 's@/XInput2.h@/XI2.h@g' -i CMakeLists.txt "src/"*.c
114 sed -e 's@Kernel/IOKit/hidsystem/IOHIDUsageTables.h@IOKit/hid/IOHIDUsageTables.h@g' -i include/allegro5/platform/alosx.h
115 sed -e 's@OpenAL/@AL/@g' -i addons/audio/openal.c
116 '';
117
118 cmakeFlags = [
119 "-DCMAKE_SKIP_RPATH=ON"
120 ]
121 ++ lib.optionals useSDL [
122 "ALLEGRO_SDL=ON"
123 ];
124
125 outputs = [
126 "out"
127 "dev"
128 ];
129
130 strictDeps = true;
131
132 passthru.updateScript = gitUpdater { };
133
134 meta = {
135 description = "Game programming library";
136 homepage = "https://liballeg.org/";
137 license = lib.licenses.zlib;
138 maintainers = [ lib.maintainers.raskin ];
139 platforms = lib.platforms.linux ++ lib.platforms.darwin;
140 };
141}