diff options
Diffstat (limited to 'customized/prosody.nix')
-rw-r--r-- | customized/prosody.nix | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/customized/prosody.nix b/customized/prosody.nix new file mode 100644 index 00000000..4a6da4fb --- /dev/null +++ b/customized/prosody.nix | |||
@@ -0,0 +1,69 @@ | |||
1 | { stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg | ||
2 | , lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop, luaevent ? null, luazlib ? null | ||
3 | , withLibevent ? true, withZlib ? true | ||
4 | , extraModules ? [], extraLibs ? [] | ||
5 | }: | ||
6 | |||
7 | assert withLibevent -> luaevent != null; | ||
8 | assert withZlib -> luazlib != null; | ||
9 | |||
10 | with stdenv.lib; | ||
11 | |||
12 | let | ||
13 | libs = [ luasocket luasec luaexpat luafilesystem luabitop ] | ||
14 | ++ optional withLibevent luaevent | ||
15 | ++ optional withZlib luazlib | ||
16 | ++ extraLibs; | ||
17 | getPath = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}"; | ||
18 | getLuaPath = lib : getPath lib "lua"; | ||
19 | getLuaCPath = lib : getPath lib "so"; | ||
20 | copyModule = name : "cp -rv $communityModules/${name} $out/lib/prosody/modules/" | ||
21 | luaPath = concatStringsSep ";" (map getLuaPath libs); | ||
22 | luaCPath = concatStringsSep ";" (map getLuaCPath libs); | ||
23 | copyModules = concatStringsSep ";" (map copyModule (extraModules ++ ["mod_websocket"])); | ||
24 | in | ||
25 | |||
26 | stdenv.mkDerivation rec { | ||
27 | version = "0.9.8"; | ||
28 | name = "prosody-${version}"; | ||
29 | |||
30 | src = fetchurl { | ||
31 | url = "http://prosody.im/downloads/source/${name}.tar.gz"; | ||
32 | sha256 = "0wbq4ps69l09fjb5dfjzab6i30hzpi4bvyj5kc44gf70arf42w4l"; | ||
33 | }; | ||
34 | |||
35 | communityModules = fetchhg { | ||
36 | url = "http://prosody-modules.googlecode.com/hg/"; | ||
37 | rev = "4b55110b0aa8"; | ||
38 | sha256 = "0010x2rl9f9ihy2nwqan2jdlz25433srj2zna1xh10490mc28hij"; | ||
39 | }; | ||
40 | |||
41 | buildInputs = [ lua5 luasocket luasec luaexpat luabitop libidn openssl makeWrapper ] | ||
42 | ++ optional withLibevent luaevent | ||
43 | ++ optional withZlib luazlib; | ||
44 | |||
45 | configureFlags = [ | ||
46 | "--ostype=linux" | ||
47 | "--with-lua-include=${lua5}/include" | ||
48 | "--with-lua=${lua5}" | ||
49 | ]; | ||
50 | |||
51 | postInstall = '' | ||
52 | ${copyModules} | ||
53 | wrapProgram $out/bin/prosody \ | ||
54 | --set LUA_PATH '"${luaPath};"' \ | ||
55 | --set LUA_CPATH '"${luaCPath};"' | ||
56 | wrapProgram $out/bin/prosodyctl \ | ||
57 | --add-flags '--config "/etc/prosody/prosody.cfg.lua"' \ | ||
58 | --set LUA_PATH '"${luaPath};"' \ | ||
59 | --set LUA_CPATH '"${luaCPath};"' | ||
60 | ''; | ||
61 | |||
62 | meta = { | ||
63 | description = "Open-source XMPP application server written in Lua"; | ||
64 | license = licenses.mit; | ||
65 | homepage = http://www.prosody.im; | ||
66 | platforms = platforms.linux; | ||
67 | maintainers = [ maintainers.flosse ]; | ||
68 | }; | ||
69 | } | ||