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