@@ -1,41 +1,67 @@
11{ stdenv, fetchurl }:
2+rec {
23
3−stdenv.mkDerivation rec {
4− name = "luajit-${version}";
5− version = "2.1.0-beta3";
6− luaversion = "5.1";
4+ luajit = luajit_2_1;
75
8− src = fetchurl {
9− url = "http://luajit.org/download/LuaJIT-${version}.tar.gz";
10− sha256 = "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs";
6+ luajit_2_0 = generic {
7+ version = "2.0.5";
8+ isStable = true;
9+ sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7";
1110 };
1211
13− enableParallelBuilding = true;
14−
15− patchPhase = ''
16− substituteInPlace Makefile \
17− --replace /usr/local $out
18−
19− substituteInPlace src/Makefile --replace gcc cc
20− '' + stdenv.lib.optionalString (stdenv.cc.libc != null)
21− ''
22− substituteInPlace Makefile \
23− --replace ldconfig ${stdenv.cc.libc.bin or stdenv.cc.libc}/bin/ldconfig
24− '';
25−
26− configurePhase = false;
27− buildFlags = [ "amalg" ]; # Build highly optimized version
28− installPhase = ''
29− make install INSTALL_INC=$out/include PREFIX=$out
30− ln -s $out/bin/luajit* $out/bin/lua
31− ln -s $out/bin/luajit* $out/bin/luajit
32− '';
33−
34− meta = with stdenv.lib; {
35− description = "High-performance JIT compiler for Lua 5.1";
36− homepage = http://luajit.org;
37− license = licenses.mit;
38− platforms = platforms.linux ++ platforms.darwin;
39− maintainers = with maintainers ; [ thoughtpolice smironov ];
12+ luajit_2_1 = generic {
13+ version = "2.1.0-beta3";
14+ isStable = false;
15+ sha256 = "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs";
4016 };
17+
18+
19+ generic =
20+ { version, sha256 ? null, isStable
21+ , name ? "luajit-${version}"
22+ , src ?
23+ (fetchurl {
24+ url = "http://luajit.org/download/LuaJIT-${version}.tar.gz";
25+ inherit sha256;
26+ })
27+ }:
28+
29+ stdenv.mkDerivation rec {
30+ inherit name version src;
31+
32+ luaversion = "5.1";
33+
34+ patchPhase = ''
35+ substituteInPlace Makefile \
36+ --replace /usr/local "$out"
37+
38+ substituteInPlace src/Makefile --replace gcc cc
39+ '' + stdenv.lib.optionalString (stdenv.cc.libc != null)
40+ ''
41+ substituteInPlace Makefile \
42+ --replace ldconfig ${stdenv.cc.libc.bin or stdenv.cc.libc}/bin/ldconfig
43+ '';
44+
45+ configurePhase = false;
46+
47+ buildFlags = [ "amalg" ]; # Build highly optimized version
48+ enableParallelBuilding = true;
49+
50+ installPhase = ''
51+ make install INSTALL_INC="$out"/include PREFIX="$out"
52+ ln -s "$out"/bin/luajit-* "$out"/bin/lua
53+ ''
54+ + stdenv.lib.optionalString (!isStable)
55+ ''
56+ ln -s "$out"/bin/luajit-* "$out"/bin/luajit
57+ '';
58+
59+ meta = with stdenv.lib; {
60+ description = "High-performance JIT compiler for Lua 5.1";
61+ homepage = http://luajit.org;
62+ license = licenses.mit;
63+ platforms = platforms.linux ++ platforms.darwin;
64+ maintainers = with maintainers ; [ thoughtpolice smironov vcunat ];
65+ };
66+ };
4167}