forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
lua-packages.nix
236 lines (193 loc) · 7.02 KB
/
lua-packages.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* This file defines the composition for Lua packages. It has
been factored out of all-packages.nix because there are many of
them. Also, because most Nix expressions for Lua packages are
trivial, most are actually defined here. I.e. there's no function
for each package in a separate file: the call to the function would
be almost as must code as the function itself. */
{ fetchurl, stdenv, lua, unzip, pkgconfig
, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat
, autoreconfHook, gnum4
, mysql, postgresql, cyrus_sasl
, fetchFromGitHub, which, writeText
, pkgs
, lib
}:
let
packages = ( self:
let
luaAtLeast = lib.versionAtLeast lua.luaversion;
luaOlder = lib.versionOlder lua.luaversion;
isLua51 = (lib.versions.majorMinor lua.version) == "5.1";
isLua52 = (lib.versions.majorMinor lua.version) == "5.2";
isLua53 = lua.luaversion == "5.3";
isLuaJIT = lib.getName lua == "luajit";
lua-setup-hook = callPackage ../development/interpreters/lua-5/setup-hook.nix { };
# Check whether a derivation provides a lua module.
hasLuaModule = drv: drv ? luaModule ;
callPackage = pkgs.newScope self;
requiredLuaModules = drvs: with stdenv.lib; let
modules = filter hasLuaModule drvs;
in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules));
# Convert derivation to a lua module.
toLuaModule = drv:
drv.overrideAttrs( oldAttrs: {
# Use passthru in order to prevent rebuilds when possible.
passthru = (oldAttrs.passthru or {})// {
luaModule = lua;
requiredLuaModules = requiredLuaModules drv.propagatedBuildInputs;
};
});
platformString =
if stdenv.isDarwin then "macosx"
else if stdenv.isFreeBSD then "freebsd"
else if stdenv.isLinux then "linux"
else if stdenv.isSunOS then "solaris"
else throw "unsupported platform";
buildLuaApplication = args: buildLuarocksPackage ({namePrefix="";} // args );
buildLuarocksPackage = with pkgs.lib; makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix {
inherit toLuaModule;
inherit lua;
});
in
with self; {
getLuaPathList = majorVersion: [
"share/lua/${majorVersion}/?.lua"
"share/lua/${majorVersion}/?/init.lua"
];
getLuaCPathList = majorVersion: [
"lib/lua/${majorVersion}/?.so"
];
# helper functions for dealing with LUA_PATH and LUA_CPATH
getPath = drv: pathListForVersion:
lib.concatMapStringsSep ";" (path: "${drv}/${path}") (pathListForVersion lua.luaversion);
getLuaPath = drv: getPath drv getLuaPathList;
getLuaCPath = drv: getPath drv getLuaCPathList;
#define build lua package function
buildLuaPackage = callPackage ../development/lua-modules/generic {
inherit lua writeText;
};
inherit toLuaModule lua-setup-hook;
inherit buildLuarocksPackage buildLuaApplication;
inherit requiredLuaModules luaOlder luaAtLeast
isLua51 isLua52 isLua53 isLuaJIT lua callPackage;
# wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH
wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix {
inherit lua; inherit (pkgs) makeSetupHook makeWrapper;
};
luarocks = callPackage ../development/tools/misc/luarocks {
inherit lua;
};
luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { };
luasocket-git = buildLuaPackage rec {
name = "socket-${version}";
version = "3.0-rc1";
src = fetchFromGitHub {
owner = "diegonehab";
repo = "luasocket";
rev = "v${version}";
sha256 = "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk";
};
patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace src/makefile \
--replace 10.3 10.5
'';
preBuild = ''
makeFlagsArray=(
LUAV=${lua.luaversion}
PLAT=${platformString}
CC=''${CC}
LD=''${CC}
prefix=$out
);
'';
doCheck = false; # fails to find itself
installTargets = [ "install" "install-unix" ];
meta = with stdenv.lib; {
description = "Network support for Lua";
homepage = "http://w3.impa.br/~diego/software/luasocket/";
license = licenses.mit;
maintainers = with maintainers; [ ];
platforms = with platforms; darwin ++ linux ++ freebsd ++ illumos;
};
};
luxio = buildLuaPackage rec {
name = "luxio-${version}";
version = "13";
src = fetchurl {
url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-13.tar.bz2";
sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz";
};
nativeBuildInputs = [ which pkgconfig ];
postPatch = ''
patchShebangs .
'';
preBuild = ''
makeFlagsArray=(
INST_LIBDIR="$out/lib/lua/${lua.luaversion}"
INST_LUADIR="$out/share/lua/${lua.luaversion}"
LUA_BINDIR="$out/bin"
INSTALL=install
);
'';
meta = with stdenv.lib; {
description = "Lightweight UNIX I/O and POSIX binding for Lua";
homepage = "https://www.gitano.org.uk/luxio/";
license = licenses.mit;
maintainers = with maintainers; [ richardipsum ];
platforms = platforms.unix;
};
};
pulseaudio = buildLuaPackage rec {
pname = "pulseaudio";
version = "0.2";
name = "pulseaudio-${version}";
src = fetchFromGitHub {
owner = "doronbehar";
repo = "lua-pulseaudio";
rev = "v${version}";
sha256 = "140y1m6k798c4w7xfl0zb0a4ffjz6i1722bgkdcdg8g76hr5r8ys";
};
disabled = (luaOlder "5.1") || (luaAtLeast "5.5");
buildInputs = [ pkgs.libpulseaudio ];
propagatedBuildInputs = [ lua ];
nativeBuildInputs = [ pkgs.pulseaudio pkgconfig ];
makeFlags = [
"INST_LIBDIR=${placeholder "out"}/lib/lua/${lua.luaversion}"
"INST_LUADIR=${placeholder "out"}/share/lua/${lua.luaversion}"
"LUA_BINDIR=${placeholder "out"}/bin"
];
preBuild = ''
mkdir -p ${placeholder "out"}/lib/lua/${lua.luaversion}
'';
meta = with stdenv.lib; {
homepage = "https://github.com/doronbehar/lua-pulseaudio";
description = "Libpulse Lua bindings";
maintainers = with maintainers; [ doronbehar ];
license = licenses.lgpl21;
};
};
vicious = toLuaModule(stdenv.mkDerivation rec {
pname = "vicious";
version = "2.3.1";
src = fetchFromGitHub {
owner = "Mic92";
repo = "vicious";
rev = "v${version}";
sha256 = "1yzhjn8rsvjjsfycdc993ms6jy2j5jh7x3r2ax6g02z5n0anvnbx";
};
buildInputs = [ lua ];
installPhase = ''
mkdir -p $out/lib/lua/${lua.luaversion}/
cp -r . $out/lib/lua/${lua.luaversion}/vicious/
printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua
'';
meta = with stdenv.lib; {
description = "A modular widget library for the awesome window manager";
homepage = "https://github.com/Mic92/vicious";
license = licenses.gpl2;
maintainers = with maintainers; [ makefu mic92 ];
platforms = platforms.linux;
};
});
});
in packages