1/* This file defines the composition for Lua packages. It has
2 been factored out of all-packages.nix because there are many of
3 them. Also, because most Nix expressions for Lua packages are
4 trivial, most are actually defined here. I.e. there's no function
5 for each package in a separate file: the call to the function would
6 be almost as must code as the function itself. */
7
8{ fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool
9, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo
10, perl, gtk, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook
11, fetchFromGitHub
12}:
13
14let
15 isLua51 = lua.luaversion == "5.1";
16 isLua52 = lua.luaversion == "5.2";
17 self = _self;
18 _self = with self; {
19 inherit lua;
20 inherit (stdenv.lib) maintainers;
21
22 #define build lua package function
23 buildLuaPackage = callPackage ../development/lua-modules/generic lua;
24
25 luarocks = callPackage ../development/tools/misc/luarocks {
26 inherit lua;
27 };
28
29 luabitop = buildLuaPackage rec {
30 version = "1.0.2";
31 name = "bitop-${version}";
32 src = fetchurl {
33 url = "http://bitop.luajit.org/download/LuaBitOp-${version}.tar.gz";
34 sha256 = "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj";
35 };
36
37 buildFlags = stdenv.lib.optionalString stdenv.isDarwin "macosx";
38
39 preBuild = ''
40 makeFlagsArray=(
41 ${stdenv.lib.optionalString stdenv.cc.isClang "CC=$CC"}
42 INCLUDES="-I${lua}/include"
43 LUA="${lua}/bin/lua");
44 '';
45
46 installPhase = ''
47 mkdir -p $out/lib/lua/${lua.luaversion}
48 install -p bit.so $out/lib/lua/${lua.luaversion}
49 '';
50
51 meta = {
52 homepage = "http://bitop.luajit.org";
53 maintainers = with maintainers; [ flosse ];
54 };
55 };
56
57 luaevent = buildLuaPackage rec {
58 version = "0.4.3";
59 name = "luaevent-${version}";
60 disabled = isLua52;
61
62 src = fetchzip {
63 url = "https://github.com/harningt/luaevent/archive/v${version}.tar.gz";
64 sha256 = "1c1n2zqx5rwfwkqaq1jj8gvx1vswvbihj2sy445w28icz1xfhpik";
65 };
66
67 preBuild = ''
68 makeFlagsArray=(
69 INSTALL_DIR_LUA="$out/share/lua/${lua.luaversion}"
70 INSTALL_DIR_BIN="$out/lib/lua/${lua.luaversion}"
71 LUA_INC_DIR="${lua}/include"
72 );
73 '';
74
75 buildInputs = [ libevent ];
76
77 propagatedBuildInputs = [ luasocket ];
78
79 meta = with stdenv.lib; {
80 homepage = http://luaforge.net/projects/luaevent/;
81 description = "Binding of libevent to Lua";
82 license = licenses.mit;
83 maintainers = [ maintainers.koral ];
84 };
85 };
86
87 luaexpat = buildLuaPackage rec {
88 version = "1.3.0";
89 name = "expat-${version}";
90 isLibrary = true;
91 src = fetchurl {
92 url = "https://matthewwild.co.uk/projects/luaexpat/luaexpat-${version}.tar.gz";
93 sha256 = "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h";
94 };
95
96 buildInputs = [ expat ];
97
98 preBuild = ''
99 makeFlagsArray=(
100 LUA_LDIR="$out/share/lua/${lua.luaversion}"
101 LUA_INC="-I${lua}/include" LUA_CDIR="$out/lib/lua/${lua.luaversion}"
102 EXPAT_INC="-I${expat}/include");
103 '';
104
105 meta = {
106 homepage = "http://matthewwild.co.uk/projects/luaexpat";
107 hydraPlatforms = stdenv.lib.platforms.linux;
108 maintainers = [ stdenv.lib.maintainers.flosse ];
109 };
110 };
111
112 luafilesystem = buildLuaPackage rec {
113 name = "filesystem-1.6.2";
114 src = fetchzip {
115 url = "https://github.com/keplerproject/luafilesystem/archive/v1_6_2.tar.gz";
116 sha256 = "134azkxw84xp9g5qmzjsmcva629jm7plwcmjxkdzdg05vyd7kig1";
117 };
118 meta = {
119 homepage = "https://github.com/keplerproject/luafilesystem";
120 hydraPlatforms = stdenv.lib.platforms.linux;
121 maintainers = with maintainers; [ flosse ];
122 };
123 };
124
125 lpty = buildLuaPackage rec {
126 name = "lpty-${version}";
127 version = "1.1.1";
128 src = fetchurl {
129 url = "http://www.tset.de/downloads/lpty-1.1-1.tar.gz";
130 sha256 = "0d4ffda654dcf37dd8c99bcd100d0ee0dde7782cbd0ba9200ef8711c5cab02f1";
131 };
132 meta = {
133 homepage = "http://www.tset.de/lpty";
134 hydraPlatforms = stdenv.lib.platforms.linux;
135 license = stdenv.lib.licenses.mit;
136 };
137 preBuild = ''
138 makeFlagsArray=(
139 INST_LIBDIR="$out/lib/lua/${lua.luaversion}"
140 INST_LUADIR="$out/share/lua/${lua.luaversion}"
141 LUA_BINDIR="${lua}/bin"
142 LUA_INCDIR="-I${lua}/include"
143 LUA_LIBDIR="-L${lua}/lib"
144 );
145 '';
146 };
147
148 luasec = buildLuaPackage rec {
149 name = "sec-0.6pre-2015-04-17";
150 src = fetchFromGitHub {
151 owner = "brunoos";
152 repo = "luasec";
153 rev = "12e1b1f1d9724974ecc6ca273a0661496d96b3e7";
154 sha256 = "0m917qgi54p6n2ak33m67q8sxcw3cdni99bm216phjjka9rg7qwd";
155 };
156
157 buildInputs = [ openssl ];
158
159 preBuild = ''
160 makeFlagsArray=(
161 linux
162 LUAPATH="$out/lib/lua/${lua.luaversion}"
163 LUACPATH="$out/lib/lua/${lua.luaversion}"
164 INC_PATH="-I${lua}/include"
165 LIB_PATH="-L$out/lib");
166 '';
167
168 meta = {
169 homepage = "https://github.com/brunoos/luasec";
170 hydraPlatforms = stdenv.lib.platforms.linux;
171 maintainers = [ stdenv.lib.maintainers.flosse ];
172 };
173 };
174
175 luasocket = buildLuaPackage rec {
176 name = "socket-${version}";
177 version = "2.0.2";
178 src = fetchurl {
179 url = "http://files.luaforge.net/releases/luasocket/luasocket/luasocket-${version}/luasocket-${version}.tar.gz";
180 sha256 = "19ichkbc4rxv00ggz8gyf29jibvc2wq9pqjik0ll326rrxswgnag";
181 };
182 disabled = isLua52;
183 patchPhase = ''
184 sed -e "s,^INSTALL_TOP_SHARE.*,INSTALL_TOP_SHARE=$out/share/lua/${lua.luaversion}," \
185 -e "s,^INSTALL_TOP_LIB.*,INSTALL_TOP_LIB=$out/lib/lua/${lua.luaversion}," \
186 -i config
187 '';
188 meta = {
189 homepage = "http://w3.impa.br/~diego/software/luasocket/";
190 hydraPlatforms = stdenv.lib.platforms.linux;
191 maintainers = with maintainers; [ mornfall ];
192 };
193 };
194
195 luazip = buildLuaPackage rec {
196 name = "zip-${version}";
197 version = "1.2.3";
198 src = fetchzip {
199 url = "https://github.com/luaforge/luazip/archive/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44.zip";
200 sha256 = "0zrrwhmzny5zbpx91bjbl77gzkvvdi3qhhviliggp0aj8w3faxsr";
201 };
202 buildInputs = [ unzip zziplib ];
203 patches = [ ../development/lua-modules/zip.patch ];
204 # does not currently work under lua 5.2
205 disabled = isLua52;
206 meta = {
207 homepage = "https://github.com/luaforge/luazip";
208 hydraPlatforms = stdenv.lib.platforms.linux;
209 license = stdenv.lib.licenses.mit;
210 };
211 };
212
213 luazlib = buildLuaPackage rec {
214 name = "zlib-${version}";
215 version = "0.4";
216
217 src = fetchzip {
218 url = "https://github.com/brimworks/lua-zlib/archive/v${version}.tar.gz";
219 sha256 = "1pgxnjc0gvk25wsr69nsm60y5ad86z1nlq7mzj3ckygzkgi782dd";
220 };
221
222 buildInputs = [ zlib ];
223
224 preBuild = ''
225 makeFlagsArray=(
226 linux
227 LUAPATH="$out/share/lua/${lua.luaversion}"
228 LUACPATH="$out/lib/lua/${lua.luaversion}"
229 INCDIR="-I${lua}/include"
230 LIBDIR="-L$out/lib");
231 '';
232
233 preInstall = "mkdir -p $out/lib/lua/${lua.luaversion}";
234
235 meta = with stdenv.lib; {
236 homepage = https://github.com/brimworks/lua-zlib;
237 hydraPlatforms = platforms.linux;
238 license = licenses.mit;
239 maintainers = [ maintainers.koral ];
240 };
241 };
242
243
244 luastdlib = buildLuaPackage {
245 name = "stdlib";
246 src = fetchzip {
247 url = "https://github.com/lua-stdlib/lua-stdlib/archive/release.zip";
248 sha256 = "0636absdfjx8ybglwydmqxwfwmqz1c4b9s5mhxlgm4ci18lw3hms";
249 };
250 buildInputs = [ autoreconfHook unzip ];
251 meta = {
252 homepage = "https://github.com/lua-stdlib/lua-stdlib/";
253 hydraPlatforms = stdenv.lib.platforms.linux;
254 license = stdenv.lib.licenses.mit;
255 };
256 };
257
258 lrexlib = buildLuaPackage rec {
259 name = "lrexlib-${version}";
260 version = "2.7.2";
261 src = fetchzip {
262 url = "https://github.com/rrthomas/lrexlib/archive/150c251be57c4e569da0f48bf6b01fbca97179fe.zip";
263 sha256 = "0acb3258681bjq61piz331r99bdff6cnkjaigq5phg3699iz5h75";
264 };
265 buildInputs = [ unzip luastdlib pcre luarocks oniguruma gnulib tre glibc ];
266
267 buildPhase = let
268 luaVariable = "LUA_PATH=${luastdlib}/share/lua/${lua.luaversion}/?.lua";
269
270 pcreVariable = "PCRE_DIR=${pcre}";
271 onigVariable = "ONIG_DIR=${oniguruma}";
272 gnuVariable = "GNU_INCDIR=${gnulib}/lib";
273 treVariable = "TRE_DIR=${tre}";
274 posixVariable = "POSIX_DIR=${glibc}";
275 in ''
276 sed -e 's@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i;@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i ${pcreVariable} ${onigVariable} ${gnuVariable} ${treVariable} ${posixVariable};@' \
277 -i Makefile
278 ${luaVariable} make
279 '';
280
281 installPhase = ''
282 mkdir -pv $out;
283 cp -r luarocks/lib $out;
284 '';
285
286 meta = {
287 homepage = "https://github.com/lua-stdlib/lua-stdlib/";
288 hydraPlatforms = stdenv.lib.platforms.linux;
289 license = stdenv.lib.licenses.mit;
290 broken = true;
291 };
292 };
293
294 luasqlite3 = buildLuaPackage rec {
295 name = "sqlite3-${version}";
296 version = "2.1.1";
297 src = fetchzip {
298 url = "https://github.com/LuaDist/luasql-sqlite3/archive/2acdb6cb256e63e5b5a0ddd72c4639d8c0feb52d.zip";
299 sha256 = "17zsa0jzciildil9k4lb0rjn9s1nj80dy16pzx9bxqyi75pjf2d4";
300 };
301
302 buildInputs = [ unzip sqlite ];
303
304 patches = [ ../development/lua-modules/luasql.patch ];
305
306 meta = {
307 homepage = "https://github.com/LuaDist/luasql-sqlite3";
308 hydraPlatforms = stdenv.lib.platforms.linux;
309 license = stdenv.lib.licenses.mit;
310 };
311 };
312
313 lpeg = buildLuaPackage rec {
314 name = "lpeg-${version}";
315 version = "0.12";
316 src = fetchurl {
317 url = "http://www.inf.puc-rio.br/~roberto/lpeg/${name}.tar.gz";
318 sha256 = "0xlbfw1w7l65a5qhnx5sfw327hkq1zcj8xmg4glfw6fj9ha4b9gg";
319 };
320 buildInputs = [ unzip ];
321
322 preBuild = ''
323 makeFlagsArray=(CC=$CC);
324 '';
325
326 buildFlags = if stdenv.isDarwin then "macosx" else "";
327
328 installPhase = ''
329 mkdir -p $out/lib/lua/${lua.luaversion}
330 install -p lpeg.so $out/lib/lua/${lua.luaversion}
331 install -p re.lua $out/lib/lua/${lua.luaversion}
332 '';
333
334 meta = {
335 homepage = "http://www.inf.puc-rio.br/~roberto/lpeg/";
336 hydraPlatforms = stdenv.lib.platforms.all;
337 license = stdenv.lib.licenses.mit;
338 };
339 };
340
341 cjson = buildLuaPackage rec {
342 name = "cjson-${version}";
343 version = "2.1.0";
344 src = fetchurl {
345 url = "http://www.kyne.com.au/~mark/software/download/lua-cjson-2.1.0.tar.gz";
346 sha256 = "0y67yqlsivbhshg8ma535llz90r4zag9xqza5jx0q7lkap6nkg2i";
347 };
348 preBuild = ''
349 sed -i "s|/usr/local|$out|" Makefile
350 '';
351 makeFlags = [ "LUA_VERSION=${lua.luaversion}" ];
352 postInstall = ''
353 rm -rf $out/share/lua/${lua.luaversion}/cjson/tests
354 '';
355 installTargets = "install install-extra";
356 meta = {
357 description = "Lua C extension module for JSON support";
358 license = stdenv.lib.licenses.mit;
359 };
360 };
361
362 luaMessagePack = buildLuaPackage rec {
363 name = "lua-MessagePack-${version}";
364 version = "0.3.1";
365 src = fetchzip {
366 url = "https://github.com/fperrad/lua-MessagePack/archive/${version}.tar.gz";
367 sha256 = "1xlif8fkwd8bb78wrvf2z309p7apms350lbg6qavylsvz57lkjm6";
368 };
369 buildInputs = [ unzip ];
370
371 meta = {
372 homepage = "http://fperrad.github.io/lua-MessagePack/index.html";
373 hydraPlatforms = stdenv.lib.platforms.linux;
374 license = stdenv.lib.licenses.mit;
375 };
376 };
377
378 lgi = stdenv.mkDerivation rec {
379 name = "lgi-${version}";
380 version = "0.7.2";
381
382 src = fetchzip {
383 url = "https://github.com/pavouk/lgi/archive/${version}.tar.gz";
384 sha256 = "10i2ssfs01d49fdmmriqzxc8pshys4rixhx30wzd9p1m1q47a5pn";
385 };
386
387 meta = with stdenv.lib; {
388 description = "GObject-introspection based dynamic Lua binding to GObject based libraries";
389 homepage = https://github.com/pavouk/lgi;
390 license = "custom";
391 maintainers = with maintainers; [ lovek323 ];
392 platforms = platforms.unix;
393 };
394
395 buildInputs = [ glib gobjectIntrospection lua pkgconfig ];
396
397 makeFlags = [ "LUA_VERSION=${lua.luaversion}" ];
398
399 preBuild = ''
400 sed -i "s|/usr/local|$out|" lgi/Makefile
401 '';
402 };
403
404 vicious = stdenv.mkDerivation rec {
405 name = "vicious-${version}";
406 version = "2.1.3";
407
408 src = fetchzip {
409 url = "http://git.sysphere.org/vicious/snapshot/vicious-${version}.tar.xz";
410 sha256 = "1c901siza5vpcbkgx99g1vkqiki5qgkzx2brnj4wrpbsbfzq0bcq";
411 };
412
413 meta = with stdenv.lib; {
414 description = "vicious widgets for window managers";
415 homepage = http://git.sysphere.org/vicious/;
416 license = licenses.gpl2;
417 maintainers = with maintainers; [ makefu ];
418 platforms = platforms.linux;
419 };
420
421 buildInputs = [ lua ];
422 installPhase = ''
423 mkdir -p $out/lib/lua/${lua.luaversion}/
424 cp -r . $out/lib/lua/${lua.luaversion}/vicious/
425 printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua
426 '';
427 };
428
429}; in self