Merge pull request #31006 from florianjacob/prosody

Improvements for Prosody

authored by Orivej Desh and committed by GitHub 40950f6a a16501cd

+143 -42
+55 -21
nixos/modules/services/networking/prosody.nix
··· 10 11 options = { 12 13 - # TODO: require attribute 14 key = mkOption { 15 - type = types.str; 16 - description = "Path to the key file"; 17 }; 18 19 - # TODO: require attribute 20 cert = mkOption { 21 - type = types.str; 22 - description = "Path to the certificate file"; 23 }; 24 }; 25 }; 26 27 moduleOpts = { 28 29 roster = mkOption { 30 default = true; 31 description = "Allow users to have a roster"; 32 }; 33 34 saslauth = mkOption { 35 default = true; 36 description = "Authentication for clients and servers. Recommended if you want to log in."; 37 }; 38 39 tls = mkOption { 40 default = true; 41 description = "Add support for secure TLS on c2s/s2s connections"; 42 }; 43 44 dialback = mkOption { 45 default = true; 46 description = "s2s dialback support"; 47 }; 48 49 disco = mkOption { 50 default = true; 51 description = "Service discovery"; 52 }; 53 54 legacyauth = mkOption { 55 default = true; 56 description = "Legacy authentication. Only used by some old clients and bots"; 57 }; 58 59 version = mkOption { 60 default = true; 61 description = "Replies to server version requests"; 62 }; 63 64 uptime = mkOption { 65 default = true; 66 description = "Report how long server has been running"; 67 }; 68 69 time = mkOption { 70 default = true; 71 description = "Let others know the time here on this server"; 72 }; 73 74 ping = mkOption { 75 default = true; 76 description = "Replies to XMPP pings with pongs"; 77 }; 78 79 console = mkOption { 80 default = false; 81 description = "telnet to port 5582"; 82 }; 83 84 bosh = mkOption { 85 default = false; 86 description = "Enable BOSH clients, aka 'Jabber over HTTP'"; 87 }; 88 89 httpserver = mkOption { 90 default = false; 91 description = "Serve static files from a directory over HTTP"; 92 }; 93 94 websocket = mkOption { 95 default = false; 96 description = "Enable WebSocket support"; 97 }; 98 99 }; 100 101 - createSSLOptsStr = o: 102 - if o ? key && o ? cert then 103 - ''ssl = { key = "${o.key}"; certificate = "${o.cert}"; };'' 104 - else ""; 105 106 vHostOpts = { ... }: { 107 ··· 114 }; 115 116 enabled = mkOption { 117 default = false; 118 description = "Whether to enable the virtual host"; 119 }; 120 121 ssl = mkOption { 122 - description = "Paths to SSL files"; 123 default = null; 124 - options = [ sslOpts ]; 125 }; 126 127 extraConfig = mkOption { 128 - default = ''''; 129 description = "Additional virtual host specific configuration"; 130 }; 131 ··· 144 services.prosody = { 145 146 enable = mkOption { 147 default = false; 148 description = "Whether to enable the prosody server"; 149 }; 150 151 allowRegistration = mkOption { 152 default = false; 153 description = "Allow account creation"; 154 }; ··· 156 modules = moduleOpts; 157 158 extraModules = mkOption { 159 description = "Enable custom modules"; 160 - default = []; 161 }; 162 163 virtualHosts = mkOption { ··· 183 }; 184 185 ssl = mkOption { 186 - description = "Paths to SSL files"; 187 default = null; 188 - options = [ sslOpts ]; 189 }; 190 191 admins = mkOption { 192 - description = "List of administrators of the current host"; 193 example = [ "admin1@example.com" "admin2@example.com" ]; 194 - default = []; 195 }; 196 197 extraConfig = mkOption { 198 type = types.lines; 199 - default = ''''; 200 description = "Additional prosody configuration"; 201 }; 202 ··· 263 }; 264 265 systemd.services.prosody = { 266 - 267 description = "Prosody XMPP server"; 268 after = [ "network-online.target" ]; 269 wants = [ "network-online.target" ]; 270 wantedBy = [ "multi-user.target" ]; 271 serviceConfig = { 272 User = "prosody"; 273 PIDFile = "/var/lib/prosody/prosody.pid"; 274 ExecStart = "${pkgs.prosody}/bin/prosodyctl start"; 275 }; 276 - 277 }; 278 279 };
··· 10 11 options = { 12 13 key = mkOption { 14 + type = types.path; 15 + description = "Path to the key file."; 16 }; 17 18 cert = mkOption { 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."; 27 }; 28 + 29 }; 30 }; 31 32 moduleOpts = { 33 34 roster = mkOption { 35 + type = types.bool; 36 default = true; 37 description = "Allow users to have a roster"; 38 }; 39 40 saslauth = mkOption { 41 + type = types.bool; 42 default = true; 43 description = "Authentication for clients and servers. Recommended if you want to log in."; 44 }; 45 46 tls = mkOption { 47 + type = types.bool; 48 default = true; 49 description = "Add support for secure TLS on c2s/s2s connections"; 50 }; 51 52 dialback = mkOption { 53 + type = types.bool; 54 default = true; 55 description = "s2s dialback support"; 56 }; 57 58 disco = mkOption { 59 + type = types.bool; 60 default = true; 61 description = "Service discovery"; 62 }; 63 64 legacyauth = mkOption { 65 + type = types.bool; 66 default = true; 67 description = "Legacy authentication. Only used by some old clients and bots"; 68 }; 69 70 version = mkOption { 71 + type = types.bool; 72 default = true; 73 description = "Replies to server version requests"; 74 }; 75 76 uptime = mkOption { 77 + type = types.bool; 78 default = true; 79 description = "Report how long server has been running"; 80 }; 81 82 time = mkOption { 83 + type = types.bool; 84 default = true; 85 description = "Let others know the time here on this server"; 86 }; 87 88 ping = mkOption { 89 + type = types.bool; 90 default = true; 91 description = "Replies to XMPP pings with pongs"; 92 }; 93 94 console = mkOption { 95 + type = types.bool; 96 default = false; 97 description = "telnet to port 5582"; 98 }; 99 100 bosh = mkOption { 101 + type = types.bool; 102 default = false; 103 description = "Enable BOSH clients, aka 'Jabber over HTTP'"; 104 }; 105 106 httpserver = mkOption { 107 + type = types.bool; 108 default = false; 109 description = "Serve static files from a directory over HTTP"; 110 }; 111 112 websocket = mkOption { 113 + type = types.bool; 114 default = false; 115 description = "Enable WebSocket support"; 116 }; 117 118 }; 119 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 + ''; 133 134 vHostOpts = { ... }: { 135 ··· 142 }; 143 144 enabled = mkOption { 145 + type = types.bool; 146 default = false; 147 description = "Whether to enable the virtual host"; 148 }; 149 150 ssl = mkOption { 151 + type = types.nullOr (types.submodule sslOpts); 152 default = null; 153 + description = "Paths to SSL files"; 154 }; 155 156 extraConfig = mkOption { 157 + type = types.lines; 158 + default = ""; 159 description = "Additional virtual host specific configuration"; 160 }; 161 ··· 174 services.prosody = { 175 176 enable = mkOption { 177 + type = types.bool; 178 default = false; 179 description = "Whether to enable the prosody server"; 180 }; 181 182 allowRegistration = mkOption { 183 + type = types.bool; 184 default = false; 185 description = "Allow account creation"; 186 }; ··· 188 modules = moduleOpts; 189 190 extraModules = mkOption { 191 + type = types.listOf types.str; 192 + default = []; 193 description = "Enable custom modules"; 194 }; 195 196 virtualHosts = mkOption { ··· 216 }; 217 218 ssl = mkOption { 219 + type = types.nullOr (types.submodule sslOpts); 220 default = null; 221 + description = "Paths to SSL files"; 222 }; 223 224 admins = mkOption { 225 + type = types.listOf types.str; 226 + default = []; 227 example = [ "admin1@example.com" "admin2@example.com" ]; 228 + description = "List of administrators of the current host"; 229 }; 230 231 extraConfig = mkOption { 232 type = types.lines; 233 + default = ""; 234 description = "Additional prosody configuration"; 235 }; 236 ··· 297 }; 298 299 systemd.services.prosody = { 300 description = "Prosody XMPP server"; 301 after = [ "network-online.target" ]; 302 wants = [ "network-online.target" ]; 303 wantedBy = [ "multi-user.target" ]; 304 + restartTriggers = [ config.environment.etc."prosody/prosody.cfg.lua".source ]; 305 serviceConfig = { 306 User = "prosody"; 307 + Type = "forking"; 308 PIDFile = "/var/lib/prosody/prosody.pid"; 309 ExecStart = "${pkgs.prosody}/bin/prosodyctl start"; 310 }; 311 }; 312 313 };
+1 -1
pkgs/development/interpreters/lua-5/filesystem.nix
··· 21 meta = { 22 homepage = https://github.com/keplerproject/luafilesystem; 23 hydraPlatforms = stdenv.lib.platforms.linux; 24 - maintainers = [ stdenv.lib.maintainers.flosse ]; 25 }; 26 }
··· 21 meta = { 22 homepage = https://github.com/keplerproject/luafilesystem; 23 hydraPlatforms = stdenv.lib.platforms.linux; 24 + maintainers = [ ]; 25 }; 26 }
+19 -11
pkgs/servers/xmpp/prosody/default.nix
··· 1 { stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg 2 - , lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop, luaevent ? null, luazlib ? null 3 - , withLibevent ? true, withZlib ? true }: 4 5 assert withLibevent -> luaevent != null; 6 assert withZlib -> luazlib != null; 7 8 with stdenv.lib; 9 10 let 11 libs = [ luasocket luasec luaexpat luafilesystem luabitop ] 12 ++ optional withLibevent luaevent 13 - ++ optional withZlib luazlib; 14 getPath = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}"; 15 getLuaPath = lib : getPath lib "lua"; 16 getLuaCPath = lib : getPath lib "so"; ··· 28 }; 29 30 communityModules = fetchhg { 31 - url = "http://prosody-modules.googlecode.com/hg/"; 32 - rev = "4b55110b0aa8"; 33 - sha256 = "0010x2rl9f9ihy2nwqan2jdlz25433srj2zna1xh10490mc28hij"; 34 }; 35 36 - buildInputs = [ lua5 luasocket luasec luaexpat luabitop libidn openssl makeWrapper ] 37 - ++ optional withLibevent luaevent 38 - ++ optional withZlib luazlib; 39 40 configureFlags = [ 41 "--ostype=linux" ··· 44 ]; 45 46 postInstall = '' 47 - cp $communityModules/mod_websocket/mod_websocket.lua $out/lib/prosody/modules/ 48 wrapProgram $out/bin/prosody \ 49 --set LUA_PATH '${luaPath};' \ 50 --set LUA_CPATH '${luaCPath};' ··· 59 license = licenses.mit; 60 homepage = http://www.prosody.im; 61 platforms = platforms.linux; 62 - maintainers = [ maintainers.flosse ]; 63 }; 64 }
··· 1 { stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg 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 ? [ ] }: 9 10 assert withLibevent -> luaevent != null; 11 assert withZlib -> luazlib != null; 12 + assert withDBI -> luadbi != null; 13 14 with stdenv.lib; 15 16 let 17 libs = [ luasocket luasec luaexpat luafilesystem luabitop ] 18 ++ optional withLibevent luaevent 19 + ++ optional withZlib luazlib 20 + ++ optional withDBI luadbi 21 + ++ withExtraLibs; 22 getPath = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}"; 23 getLuaPath = lib : getPath lib "lua"; 24 getLuaCPath = lib : getPath lib "so"; ··· 36 }; 37 38 communityModules = fetchhg { 39 + url = "https://hg.prosody.im/prosody-modules"; 40 + rev = "9a3e51f348fe"; 41 + sha256 = "09g4vi52rv0r3jzcm0bsgp4ngqq6iapfbxfh0l7qj36qnajp4vm6"; 42 }; 43 44 + buildInputs = [ lua5 makeWrapper libidn openssl ]; 45 46 configureFlags = [ 47 "--ostype=linux" ··· 50 ]; 51 52 postInstall = '' 53 + ${concatMapStringsSep "\n" (module: '' 54 + cp -r $communityModules/mod_${module} $out/lib/prosody/modules/ 55 + '') withCommunityModules} 56 wrapProgram $out/bin/prosody \ 57 --set LUA_PATH '${luaPath};' \ 58 --set LUA_CPATH '${luaCPath};' ··· 67 license = licenses.mit; 68 homepage = http://www.prosody.im; 69 platforms = platforms.linux; 70 + maintainers = [ ]; 71 }; 72 }
+1 -1
pkgs/top-level/all-packages.nix
··· 11606 11607 prosody = callPackage ../servers/xmpp/prosody { 11608 lua5 = lua5_1; 11609 - inherit (lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib; 11610 }; 11611 11612 biboumi = callPackage ../servers/xmpp/biboumi { };
··· 11606 11607 prosody = callPackage ../servers/xmpp/prosody { 11608 lua5 = lua5_1; 11609 + inherit (lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib luadbi; 11610 }; 11611 11612 biboumi = callPackage ../servers/xmpp/biboumi { };
+67 -8
pkgs/top-level/lua-packages.nix
··· 8 { fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool 9 , pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo 10 , perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook 11 , fetchFromGitHub, libmpack, which 12 }: 13 ··· 71 description = "C extension module for Lua which adds bitwise operations on numbers"; 72 homepage = "http://bitop.luajit.org"; 73 license = licenses.mit; 74 - maintainers = with maintainers; [ flosse ]; 75 }; 76 }; 77 ··· 105 }; 106 }; 107 108 luaevent = buildLuaPackage rec { 109 version = "0.4.3"; 110 name = "luaevent-${version}"; ··· 140 luaexpat = buildLuaPackage rec { 141 version = "1.3.0"; 142 name = "expat-${version}"; 143 - isLibrary = true; 144 145 src = fetchurl { 146 url = "https://matthewwild.co.uk/projects/luaexpat/luaexpat-${version}.tar.gz"; ··· 172 }; 173 }; 174 175 luafilesystem = buildLuaPackage rec { 176 - name = "filesystem-1.6.2"; 177 178 src = fetchFromGitHub { 179 owner = "keplerproject"; 180 repo = "luafilesystem"; 181 - rev = "v1_6_2"; 182 - sha256 = "134azkxw84xp9g5qmzjsmcva629jm7plwcmjxkdzdg05vyd7kig1"; 183 }; 184 185 preConfigure = '' ··· 224 }; 225 226 lpty = buildLuaPackage rec { 227 name = "lpty-${version}"; 228 - version = "1.1.1"; 229 230 src = fetchurl { 231 - url = "http://www.tset.de/downloads/lpty-1.1-1.tar.gz"; 232 - sha256 = "0d4ffda654dcf37dd8c99bcd100d0ee0dde7782cbd0ba9200ef8711c5cab02f1"; 233 }; 234 235 preBuild = '' ··· 330 prefix=$out 331 ); 332 ''; 333 334 meta = with stdenv.lib; { 335 description = "Network support for Lua";
··· 8 { fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool 9 , pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo 10 , perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook 11 + , libmysql, postgresql, cyrus_sasl 12 , fetchFromGitHub, libmpack, which 13 }: 14 ··· 72 description = "C extension module for Lua which adds bitwise operations on numbers"; 73 homepage = "http://bitop.luajit.org"; 74 license = licenses.mit; 75 + maintainers = with maintainers; [ ]; 76 }; 77 }; 78 ··· 106 }; 107 }; 108 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 + 138 luaevent = buildLuaPackage rec { 139 version = "0.4.3"; 140 name = "luaevent-${version}"; ··· 170 luaexpat = buildLuaPackage rec { 171 version = "1.3.0"; 172 name = "expat-${version}"; 173 174 src = fetchurl { 175 url = "https://matthewwild.co.uk/projects/luaexpat/luaexpat-${version}.tar.gz"; ··· 201 }; 202 }; 203 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 + 231 luafilesystem = buildLuaPackage rec { 232 + version = "1.6.3"; 233 + name = "filesystem-${version}"; 234 235 src = fetchFromGitHub { 236 owner = "keplerproject"; 237 repo = "luafilesystem"; 238 + rev = "v${stdenv.lib.replaceChars ["."] ["_"] version}"; 239 + sha256 = "1hxcnqj53540ysyw8fzax7f09pl98b8f55s712gsglcdxp2g2pri"; 240 }; 241 242 preConfigure = '' ··· 281 }; 282 283 lpty = buildLuaPackage rec { 284 + version = "1.2.1"; 285 name = "lpty-${version}"; 286 287 src = fetchurl { 288 + url = "http://www.tset.de/downloads/lpty-${version}-1.tar.gz"; 289 + sha256 = "0rgvbpymcgdkzdwfag607xfscs9xyqxg0dj0qr5fv906mi183gs6"; 290 }; 291 292 preBuild = '' ··· 387 prefix=$out 388 ); 389 ''; 390 + 391 + installTargets = [ "install" "install-unix" ]; 392 393 meta = with stdenv.lib; { 394 description = "Network support for Lua";