git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #31006 from florianjacob/prosody

Improvements for Prosody

commit40950f6a2d081797957ac26b59655d96d26ff770 authorOrivej Desh <orivej@gmx.fr> dateSat 9 Dec 2017, 09:19 (9 years ago) parenta16501cc84cb83
5 files changed+143−42
nixos/modules/services/networking/prosody.nix+55−21 pkgs/development/interpreters/lua-5/filesystem.nix+1−1 pkgs/servers/xmpp/prosody/default.nix+19−11 pkgs/top-level/all-packages.nix+1−1 pkgs/top-level/lua-packages.nix+67−8
nixos/modules/services/networking/prosody.nix+55−21
@@ -10,98 +10,126 @@ let
1010
1111 options = {
1212
13− # TODO: require attribute
1413 key = mkOption {
15− type = types.str;
16− description = "Path to the key file";
14+ type = types.path;
15+ description = "Path to the key file.";
1716 };
1817
19− # TODO: require attribute
2018 cert = mkOption {
21− type = types.str;
22− description = "Path to the certificate file";
19+ type = types.path;
20+ description = "Path to the certificate file.";
21+ };
22+
23+ extraOptions = mkOption {
24+ type = types.attrs;
25+ default = {};
26+ description = "Extra SSL configuration options.";
2327 };
28+
2429 };
2530 };
2631
2732 moduleOpts = {
2833
2934 roster = mkOption {
35+ type = types.bool;
3036 default = true;
3137 description = "Allow users to have a roster";
3238 };
3339
3440 saslauth = mkOption {
41+ type = types.bool;
3542 default = true;
3643 description = "Authentication for clients and servers. Recommended if you want to log in.";
3744 };
3845
3946 tls = mkOption {
47+ type = types.bool;
4048 default = true;
4149 description = "Add support for secure TLS on c2s/s2s connections";
4250 };
4351
4452 dialback = mkOption {
53+ type = types.bool;
4554 default = true;
4655 description = "s2s dialback support";
4756 };
4857
4958 disco = mkOption {
59+ type = types.bool;
5060 default = true;
5161 description = "Service discovery";
5262 };
5363
5464 legacyauth = mkOption {
65+ type = types.bool;
5566 default = true;
5667 description = "Legacy authentication. Only used by some old clients and bots";
5768 };
5869
5970 version = mkOption {
71+ type = types.bool;
6072 default = true;
6173 description = "Replies to server version requests";
6274 };
6375
6476 uptime = mkOption {
77+ type = types.bool;
6578 default = true;
6679 description = "Report how long server has been running";
6780 };
6881
6982 time = mkOption {
83+ type = types.bool;
7084 default = true;
7185 description = "Let others know the time here on this server";
7286 };
7387
7488 ping = mkOption {
89+ type = types.bool;
7590 default = true;
7691 description = "Replies to XMPP pings with pongs";
7792 };
7893
7994 console = mkOption {
95+ type = types.bool;
8096 default = false;
8197 description = "telnet to port 5582";
8298 };
8399
84100 bosh = mkOption {
101+ type = types.bool;
85102 default = false;
86103 description = "Enable BOSH clients, aka 'Jabber over HTTP'";
87104 };
88105
89106 httpserver = mkOption {
107+ type = types.bool;
90108 default = false;
91109 description = "Serve static files from a directory over HTTP";
92110 };
93111
94112 websocket = mkOption {
113+ type = types.bool;
95114 default = false;
96115 description = "Enable WebSocket support";
97116 };
98117
99118 };
100119
101− createSSLOptsStr = o:
102− if o ? key && o ? cert then
103− ''ssl = { key = "${o.key}"; certificate = "${o.cert}"; };''
104− else "";
120+ toLua = x:
121+ if builtins.isString x then ''"${x}"''
122+ else if builtins.isBool x then toString x
123+ else if builtins.isInt x then toString x
124+ else throw "Invalid Lua value";
125+
126+ createSSLOptsStr = o: ''
127+ ssl = {
128+ key = "${o.key}";
129+ certificate = "${o.cert}";
130+ ${concatStringsSep "\n" (mapAttrsToList (name: value: "${name} = ${toLua value};") o.extraOptions)}
131+ };
132+ '';
105133
106134 vHostOpts = { ... }: {
107135
@@ -114,18 +142,20 @@ let
114142 };
115143
116144 enabled = mkOption {
145+ type = types.bool;
117146 default = false;
118147 description = "Whether to enable the virtual host";
119148 };
120149
121150 ssl = mkOption {
122− description = "Paths to SSL files";
151+ type = types.nullOr (types.submodule sslOpts);
123152 default = null;
124− options = [ sslOpts ];
153+ description = "Paths to SSL files";
125154 };
126155
127156 extraConfig = mkOption {
128− default = '''';
157+ type = types.lines;
158+ default = "";
129159 description = "Additional virtual host specific configuration";
130160 };
131161
@@ -144,11 +174,13 @@ in
144174 services.prosody = {
145175
146176 enable = mkOption {
177+ type = types.bool;
147178 default = false;
148179 description = "Whether to enable the prosody server";
149180 };
150181
151182 allowRegistration = mkOption {
183+ type = types.bool;
152184 default = false;
153185 description = "Allow account creation";
154186 };
@@ -156,8 +188,9 @@ in
156188 modules = moduleOpts;
157189
158190 extraModules = mkOption {
159− description = "Enable custom modules";
191+ type = types.listOf types.str;
160192 default = [];
193+ description = "Enable custom modules";
161194 };
162195
163196 virtualHosts = mkOption {
@@ -183,20 +216,21 @@ in
183216 };
184217
185218 ssl = mkOption {
186− description = "Paths to SSL files";
219+ type = types.nullOr (types.submodule sslOpts);
187220 default = null;
188− options = [ sslOpts ];
221+ description = "Paths to SSL files";
189222 };
190223
191224 admins = mkOption {
192− description = "List of administrators of the current host";
193− example = [ "admin1@example.com" "admin2@example.com" ];
225+ type = types.listOf types.str;
194226 default = [];
227+ example = [ "admin1@example.com" "admin2@example.com" ];
228+ description = "List of administrators of the current host";
195229 };
196230
197231 extraConfig = mkOption {
198232 type = types.lines;
199− default = '''';
233+ default = "";
200234 description = "Additional prosody configuration";
201235 };
202236
@@ -263,17 +297,17 @@ in
263297 };
264298
265299 systemd.services.prosody = {
266−
267300 description = "Prosody XMPP server";
268301 after = [ "network-online.target" ];
269302 wants = [ "network-online.target" ];
270303 wantedBy = [ "multi-user.target" ];
304+ restartTriggers = [ config.environment.etc."prosody/prosody.cfg.lua".source ];
271305 serviceConfig = {
272306 User = "prosody";
307+ Type = "forking";
273308 PIDFile = "/var/lib/prosody/prosody.pid";
274309 ExecStart = "${pkgs.prosody}/bin/prosodyctl start";
275310 };
276−
277311 };
278312
279313 };
pkgs/development/interpreters/lua-5/filesystem.nix+1−1
@@ -21,6 +21,6 @@ stdenv.mkDerivation rec {
2121 meta = {
2222 homepage = https://github.com/keplerproject/luafilesystem;
2323 hydraPlatforms = stdenv.lib.platforms.linux;
24− maintainers = [ stdenv.lib.maintainers.flosse ];
24+ maintainers = [ ];
2525 };
2626}
pkgs/servers/xmpp/prosody/default.nix+19−11
@@ -1,16 +1,24 @@
11{ stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg
2−, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop, luaevent ? null, luazlib ? null
3−, withLibevent ? true, withZlib ? true }:
2+, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop
3+, withLibevent ? true, luaevent ? null
4+, withZlib ? true, luazlib ? null
5+, withDBI ? true, luadbi ? null
6+# use withExtraLibs to add additional dependencies of community modules
7+, withExtraLibs ? [ ]
8+, withCommunityModules ? [ ] }:
49
510assert withLibevent -> luaevent != null;
611assert withZlib -> luazlib != null;
12+assert withDBI -> luadbi != null;
713
814with stdenv.lib;
915
1016let
1117 libs = [ luasocket luasec luaexpat luafilesystem luabitop ]
1218 ++ optional withLibevent luaevent
13− ++ optional withZlib luazlib;
19+ ++ optional withZlib luazlib
20+ ++ optional withDBI luadbi
21+ ++ withExtraLibs;
1422 getPath = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}";
1523 getLuaPath = lib : getPath lib "lua";
1624 getLuaCPath = lib : getPath lib "so";
@@ -28,14 +36,12 @@ stdenv.mkDerivation rec {
2836 };
2937
3038 communityModules = fetchhg {
31− url = "http://prosody-modules.googlecode.com/hg/";
32− rev = "4b55110b0aa8";
33− sha256 = "0010x2rl9f9ihy2nwqan2jdlz25433srj2zna1xh10490mc28hij";
39+ url = "https://hg.prosody.im/prosody-modules";
40+ rev = "9a3e51f348fe";
41+ sha256 = "09g4vi52rv0r3jzcm0bsgp4ngqq6iapfbxfh0l7qj36qnajp4vm6";
3442 };
3543
36− buildInputs = [ lua5 luasocket luasec luaexpat luabitop libidn openssl makeWrapper ]
37− ++ optional withLibevent luaevent
38− ++ optional withZlib luazlib;
44+ buildInputs = [ lua5 makeWrapper libidn openssl ];
3945
4046 configureFlags = [
4147 "--ostype=linux"
@@ -44,7 +50,9 @@ stdenv.mkDerivation rec {
4450 ];
4551
4652 postInstall = ''
47− cp $communityModules/mod_websocket/mod_websocket.lua $out/lib/prosody/modules/
53+ ${concatMapStringsSep "\n" (module: ''
54+ cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
55+ '') withCommunityModules}
4856 wrapProgram $out/bin/prosody \
4957 --set LUA_PATH '${luaPath};' \
5058 --set LUA_CPATH '${luaCPath};'
@@ -59,6 +67,6 @@ stdenv.mkDerivation rec {
5967 license = licenses.mit;
6068 homepage = http://www.prosody.im;
6169 platforms = platforms.linux;
62− maintainers = [ maintainers.flosse ];
70+ maintainers = [ ];
6371 };
6472}
pkgs/top-level/all-packages.nix+1−1
@@ -11606,7 +11606,7 @@ with pkgs;
1160611606
1160711607 prosody = callPackage ../servers/xmpp/prosody {
1160811608 lua5 = lua5_1;
11609− inherit (lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib;
11609+ inherit (lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib luadbi;
1161011610 };
1161111611
1161211612 biboumi = callPackage ../servers/xmpp/biboumi { };
pkgs/top-level/lua-packages.nix+67−8
@@ -8,6 +8,7 @@
88{ fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool
99, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo
1010, perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook
11+, libmysql, postgresql, cyrus_sasl
1112, fetchFromGitHub, libmpack, which
1213}:
1314
@@ -71,7 +72,7 @@ let
7172 description = "C extension module for Lua which adds bitwise operations on numbers";
7273 homepage = "http://bitop.luajit.org";
7374 license = licenses.mit;
74− maintainers = with maintainers; [ flosse ];
75+ maintainers = with maintainers; [ ];
7576 };
7677 };
7778
@@ -105,6 +106,35 @@ let
105106 };
106107 };
107108
109+ luacyrussasl = buildLuaPackage rec {
110+ version = "1.1.0";
111+ name = "lua-cyrussasl-${version}";
112+ src = fetchFromGitHub {
113+ owner = "JorjBauer";
114+ repo = "lua-cyrussasl";
115+ rev = "v${version}";
116+ sha256 = "14kzm3vk96k2i1m9f5zvpvq4pnzaf7s91h5g4h4x2bq1mynzw2s1";
117+ };
118+
119+ preBuild = ''
120+ makeFlagsArray=(
121+ CFLAGS="-O2 -fPIC"
122+ LDFLAGS="-O -shared -fpic -lsasl2"
123+ LUAPATH="$out/share/lua/${lua.luaversion}"
124+ CPATH="$out/lib/lua/${lua.luaversion}"
125+ );
126+ mkdir -p $out/{share,lib}/lua/${lua.luaversion}
127+ '';
128+
129+ buildInputs = [ cyrus_sasl ];
130+
131+ meta = with stdenv.lib; {
132+ homepage = "https://github.com/JorjBauer/lua-cyrussasl";
133+ description = "Cyrus SASL library for Lua 5.1+";
134+ license = licenses.bsd3;
135+ };
136+ };
137+
108138 luaevent = buildLuaPackage rec {
109139 version = "0.4.3";
110140 name = "luaevent-${version}";
@@ -140,7 +170,6 @@ let
140170 luaexpat = buildLuaPackage rec {
141171 version = "1.3.0";
142172 name = "expat-${version}";
143− isLibrary = true;
144173
145174 src = fetchurl {
146175 url = "https://matthewwild.co.uk/projects/luaexpat/luaexpat-${version}.tar.gz";
@@ -172,14 +201,42 @@ let
172201 };
173202 };
174203
204+ luadbi = buildLuaPackage rec {
205+ name = "luadbi-${version}";
206+ version = "0.5";
207+ src = fetchurl {
208+ url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/luadbi/luadbi.${version}.tar.gz";
209+ sha256 = "07ikxgxgfpimnwf7zrqwcwma83ss3wm2nzjxpwv2a1c0vmc684a9";
210+ };
211+ sourceRoot = ".";
212+
213+ buildInputs = [ libmysql postgresql sqlite ];
214+
215+ NIX_CFLAGS_COMPILE = [
216+ "-I${libmysql.dev}/include/mysql"
217+ "-I${postgresql}/include/server"
218+ ];
219+
220+ installPhase = ''
221+ mkdir -p $out/lib/lua/${lua.luaversion}
222+ install -p DBI.lua *.so $out/lib/lua/${lua.luaversion}
223+ '';
224+
225+ meta = with stdenv.lib; {
226+ homepage = "https://code.google.com/archive/p/luadbi/";
227+ platforms = stdenv.lib.platforms.unix;
228+ };
229+ };
230+
175231 luafilesystem = buildLuaPackage rec {
176− name = "filesystem-1.6.2";
232+ version = "1.6.3";
233+ name = "filesystem-${version}";
177234
178235 src = fetchFromGitHub {
179236 owner = "keplerproject";
180237 repo = "luafilesystem";
181− rev = "v1_6_2";
182− sha256 = "134azkxw84xp9g5qmzjsmcva629jm7plwcmjxkdzdg05vyd7kig1";
238+ rev = "v${stdenv.lib.replaceChars ["."] ["_"] version}";
239+ sha256 = "1hxcnqj53540ysyw8fzax7f09pl98b8f55s712gsglcdxp2g2pri";
183240 };
184241
185242 preConfigure = ''
@@ -224,12 +281,12 @@ let
224281 };
225282
226283 lpty = buildLuaPackage rec {
284+ version = "1.2.1";
227285 name = "lpty-${version}";
228− version = "1.1.1";
229286
230287 src = fetchurl {
231− url = "http://www.tset.de/downloads/lpty-1.1-1.tar.gz";
232− sha256 = "0d4ffda654dcf37dd8c99bcd100d0ee0dde7782cbd0ba9200ef8711c5cab02f1";
288+ url = "http://www.tset.de/downloads/lpty-${version}-1.tar.gz";
289+ sha256 = "0rgvbpymcgdkzdwfag607xfscs9xyqxg0dj0qr5fv906mi183gs6";
233290 };
234291
235292 preBuild = ''
@@ -331,6 +388,8 @@ let
331388 );
332389 '';
333390
391+ installTargets = [ "install" "install-unix" ];
392+
334393 meta = with stdenv.lib; {
335394 description = "Network support for Lua";
336395 homepage = "http://w3.impa.br/~diego/software/luasocket/";