Merge pull request #31006 from florianjacob/prosody

Improvements for Prosody
This commit is contained in:
Orivej Desh 2017-12-09 09:19:24 +00:00 committed by GitHub
commit 40950f6a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 143 additions and 42 deletions

View File

@ -10,98 +10,126 @@ let
options = {
# TODO: require attribute
key = mkOption {
type = types.str;
description = "Path to the key file";
type = types.path;
description = "Path to the key file.";
};
# TODO: require attribute
cert = mkOption {
type = types.str;
description = "Path to the certificate file";
type = types.path;
description = "Path to the certificate file.";
};
extraOptions = mkOption {
type = types.attrs;
default = {};
description = "Extra SSL configuration options.";
};
};
};
moduleOpts = {
roster = mkOption {
type = types.bool;
default = true;
description = "Allow users to have a roster";
};
saslauth = mkOption {
type = types.bool;
default = true;
description = "Authentication for clients and servers. Recommended if you want to log in.";
};
tls = mkOption {
type = types.bool;
default = true;
description = "Add support for secure TLS on c2s/s2s connections";
};
dialback = mkOption {
type = types.bool;
default = true;
description = "s2s dialback support";
};
disco = mkOption {
type = types.bool;
default = true;
description = "Service discovery";
};
legacyauth = mkOption {
type = types.bool;
default = true;
description = "Legacy authentication. Only used by some old clients and bots";
};
version = mkOption {
type = types.bool;
default = true;
description = "Replies to server version requests";
};
uptime = mkOption {
type = types.bool;
default = true;
description = "Report how long server has been running";
};
time = mkOption {
type = types.bool;
default = true;
description = "Let others know the time here on this server";
};
ping = mkOption {
type = types.bool;
default = true;
description = "Replies to XMPP pings with pongs";
};
console = mkOption {
type = types.bool;
default = false;
description = "telnet to port 5582";
};
bosh = mkOption {
type = types.bool;
default = false;
description = "Enable BOSH clients, aka 'Jabber over HTTP'";
};
httpserver = mkOption {
type = types.bool;
default = false;
description = "Serve static files from a directory over HTTP";
};
websocket = mkOption {
type = types.bool;
default = false;
description = "Enable WebSocket support";
};
};
createSSLOptsStr = o:
if o ? key && o ? cert then
''ssl = { key = "${o.key}"; certificate = "${o.cert}"; };''
else "";
toLua = x:
if builtins.isString x then ''"${x}"''
else if builtins.isBool x then toString x
else if builtins.isInt x then toString x
else throw "Invalid Lua value";
createSSLOptsStr = o: ''
ssl = {
key = "${o.key}";
certificate = "${o.cert}";
${concatStringsSep "\n" (mapAttrsToList (name: value: "${name} = ${toLua value};") o.extraOptions)}
};
'';
vHostOpts = { ... }: {
@ -114,18 +142,20 @@ let
};
enabled = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the virtual host";
};
ssl = mkOption {
description = "Paths to SSL files";
type = types.nullOr (types.submodule sslOpts);
default = null;
options = [ sslOpts ];
description = "Paths to SSL files";
};
extraConfig = mkOption {
default = '''';
type = types.lines;
default = "";
description = "Additional virtual host specific configuration";
};
@ -144,11 +174,13 @@ in
services.prosody = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the prosody server";
};
allowRegistration = mkOption {
type = types.bool;
default = false;
description = "Allow account creation";
};
@ -156,8 +188,9 @@ in
modules = moduleOpts;
extraModules = mkOption {
description = "Enable custom modules";
type = types.listOf types.str;
default = [];
description = "Enable custom modules";
};
virtualHosts = mkOption {
@ -183,20 +216,21 @@ in
};
ssl = mkOption {
description = "Paths to SSL files";
type = types.nullOr (types.submodule sslOpts);
default = null;
options = [ sslOpts ];
description = "Paths to SSL files";
};
admins = mkOption {
description = "List of administrators of the current host";
example = [ "admin1@example.com" "admin2@example.com" ];
type = types.listOf types.str;
default = [];
example = [ "admin1@example.com" "admin2@example.com" ];
description = "List of administrators of the current host";
};
extraConfig = mkOption {
type = types.lines;
default = '''';
default = "";
description = "Additional prosody configuration";
};
@ -263,17 +297,17 @@ in
};
systemd.services.prosody = {
description = "Prosody XMPP server";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
restartTriggers = [ config.environment.etc."prosody/prosody.cfg.lua".source ];
serviceConfig = {
User = "prosody";
Type = "forking";
PIDFile = "/var/lib/prosody/prosody.pid";
ExecStart = "${pkgs.prosody}/bin/prosodyctl start";
};
};
};

View File

@ -21,6 +21,6 @@ stdenv.mkDerivation rec {
meta = {
homepage = https://github.com/keplerproject/luafilesystem;
hydraPlatforms = stdenv.lib.platforms.linux;
maintainers = [ stdenv.lib.maintainers.flosse ];
maintainers = [ ];
};
}

View File

@ -1,16 +1,24 @@
{ stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg
, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop, luaevent ? null, luazlib ? null
, withLibevent ? true, withZlib ? true }:
, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop
, withLibevent ? true, luaevent ? null
, withZlib ? true, luazlib ? null
, withDBI ? true, luadbi ? null
# use withExtraLibs to add additional dependencies of community modules
, withExtraLibs ? [ ]
, withCommunityModules ? [ ] }:
assert withLibevent -> luaevent != null;
assert withZlib -> luazlib != null;
assert withDBI -> luadbi != null;
with stdenv.lib;
let
libs = [ luasocket luasec luaexpat luafilesystem luabitop ]
++ optional withLibevent luaevent
++ optional withZlib luazlib;
++ optional withZlib luazlib
++ optional withDBI luadbi
++ withExtraLibs;
getPath = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}";
getLuaPath = lib : getPath lib "lua";
getLuaCPath = lib : getPath lib "so";
@ -28,14 +36,12 @@ stdenv.mkDerivation rec {
};
communityModules = fetchhg {
url = "http://prosody-modules.googlecode.com/hg/";
rev = "4b55110b0aa8";
sha256 = "0010x2rl9f9ihy2nwqan2jdlz25433srj2zna1xh10490mc28hij";
url = "https://hg.prosody.im/prosody-modules";
rev = "9a3e51f348fe";
sha256 = "09g4vi52rv0r3jzcm0bsgp4ngqq6iapfbxfh0l7qj36qnajp4vm6";
};
buildInputs = [ lua5 luasocket luasec luaexpat luabitop libidn openssl makeWrapper ]
++ optional withLibevent luaevent
++ optional withZlib luazlib;
buildInputs = [ lua5 makeWrapper libidn openssl ];
configureFlags = [
"--ostype=linux"
@ -44,7 +50,9 @@ stdenv.mkDerivation rec {
];
postInstall = ''
cp $communityModules/mod_websocket/mod_websocket.lua $out/lib/prosody/modules/
${concatMapStringsSep "\n" (module: ''
cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
'') withCommunityModules}
wrapProgram $out/bin/prosody \
--set LUA_PATH '${luaPath};' \
--set LUA_CPATH '${luaCPath};'
@ -59,6 +67,6 @@ stdenv.mkDerivation rec {
license = licenses.mit;
homepage = http://www.prosody.im;
platforms = platforms.linux;
maintainers = [ maintainers.flosse ];
maintainers = [ ];
};
}

View File

@ -11606,7 +11606,7 @@ with pkgs;
prosody = callPackage ../servers/xmpp/prosody {
lua5 = lua5_1;
inherit (lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib;
inherit (lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib luadbi;
};
biboumi = callPackage ../servers/xmpp/biboumi { };

View File

@ -8,6 +8,7 @@
{ fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool
, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo
, perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook
, libmysql, postgresql, cyrus_sasl
, fetchFromGitHub, libmpack, which
}:
@ -71,7 +72,7 @@ let
description = "C extension module for Lua which adds bitwise operations on numbers";
homepage = "http://bitop.luajit.org";
license = licenses.mit;
maintainers = with maintainers; [ flosse ];
maintainers = with maintainers; [ ];
};
};
@ -105,6 +106,35 @@ let
};
};
luacyrussasl = buildLuaPackage rec {
version = "1.1.0";
name = "lua-cyrussasl-${version}";
src = fetchFromGitHub {
owner = "JorjBauer";
repo = "lua-cyrussasl";
rev = "v${version}";
sha256 = "14kzm3vk96k2i1m9f5zvpvq4pnzaf7s91h5g4h4x2bq1mynzw2s1";
};
preBuild = ''
makeFlagsArray=(
CFLAGS="-O2 -fPIC"
LDFLAGS="-O -shared -fpic -lsasl2"
LUAPATH="$out/share/lua/${lua.luaversion}"
CPATH="$out/lib/lua/${lua.luaversion}"
);
mkdir -p $out/{share,lib}/lua/${lua.luaversion}
'';
buildInputs = [ cyrus_sasl ];
meta = with stdenv.lib; {
homepage = "https://github.com/JorjBauer/lua-cyrussasl";
description = "Cyrus SASL library for Lua 5.1+";
license = licenses.bsd3;
};
};
luaevent = buildLuaPackage rec {
version = "0.4.3";
name = "luaevent-${version}";
@ -140,7 +170,6 @@ let
luaexpat = buildLuaPackage rec {
version = "1.3.0";
name = "expat-${version}";
isLibrary = true;
src = fetchurl {
url = "https://matthewwild.co.uk/projects/luaexpat/luaexpat-${version}.tar.gz";
@ -172,14 +201,42 @@ let
};
};
luadbi = buildLuaPackage rec {
name = "luadbi-${version}";
version = "0.5";
src = fetchurl {
url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/luadbi/luadbi.${version}.tar.gz";
sha256 = "07ikxgxgfpimnwf7zrqwcwma83ss3wm2nzjxpwv2a1c0vmc684a9";
};
sourceRoot = ".";
buildInputs = [ libmysql postgresql sqlite ];
NIX_CFLAGS_COMPILE = [
"-I${libmysql.dev}/include/mysql"
"-I${postgresql}/include/server"
];
installPhase = ''
mkdir -p $out/lib/lua/${lua.luaversion}
install -p DBI.lua *.so $out/lib/lua/${lua.luaversion}
'';
meta = with stdenv.lib; {
homepage = "https://code.google.com/archive/p/luadbi/";
platforms = stdenv.lib.platforms.unix;
};
};
luafilesystem = buildLuaPackage rec {
name = "filesystem-1.6.2";
version = "1.6.3";
name = "filesystem-${version}";
src = fetchFromGitHub {
owner = "keplerproject";
repo = "luafilesystem";
rev = "v1_6_2";
sha256 = "134azkxw84xp9g5qmzjsmcva629jm7plwcmjxkdzdg05vyd7kig1";
rev = "v${stdenv.lib.replaceChars ["."] ["_"] version}";
sha256 = "1hxcnqj53540ysyw8fzax7f09pl98b8f55s712gsglcdxp2g2pri";
};
preConfigure = ''
@ -224,12 +281,12 @@ let
};
lpty = buildLuaPackage rec {
version = "1.2.1";
name = "lpty-${version}";
version = "1.1.1";
src = fetchurl {
url = "http://www.tset.de/downloads/lpty-1.1-1.tar.gz";
sha256 = "0d4ffda654dcf37dd8c99bcd100d0ee0dde7782cbd0ba9200ef8711c5cab02f1";
url = "http://www.tset.de/downloads/lpty-${version}-1.tar.gz";
sha256 = "0rgvbpymcgdkzdwfag607xfscs9xyqxg0dj0qr5fv906mi183gs6";
};
preBuild = ''
@ -331,6 +388,8 @@ let
);
'';
installTargets = [ "install" "install-unix" ];
meta = with stdenv.lib; {
description = "Network support for Lua";
homepage = "http://w3.impa.br/~diego/software/luasocket/";