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

View File

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

View File

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

View File

@ -11606,7 +11606,7 @@ with pkgs;
prosody = callPackage ../servers/xmpp/prosody { prosody = callPackage ../servers/xmpp/prosody {
lua5 = lua5_1; 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 { }; biboumi = callPackage ../servers/xmpp/biboumi { };

View File

@ -8,6 +8,7 @@
{ fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool { fetchurl, fetchzip, stdenv, lua, callPackage, unzip, zziplib, pkgconfig, libtool
, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo , pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo
, perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook , perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook
, libmysql, postgresql, cyrus_sasl
, fetchFromGitHub, libmpack, which , fetchFromGitHub, libmpack, which
}: }:
@ -71,7 +72,7 @@ let
description = "C extension module for Lua which adds bitwise operations on numbers"; description = "C extension module for Lua which adds bitwise operations on numbers";
homepage = "http://bitop.luajit.org"; homepage = "http://bitop.luajit.org";
license = licenses.mit; 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 { luaevent = buildLuaPackage rec {
version = "0.4.3"; version = "0.4.3";
name = "luaevent-${version}"; name = "luaevent-${version}";
@ -140,7 +170,6 @@ let
luaexpat = buildLuaPackage rec { luaexpat = buildLuaPackage rec {
version = "1.3.0"; version = "1.3.0";
name = "expat-${version}"; name = "expat-${version}";
isLibrary = true;
src = fetchurl { src = fetchurl {
url = "https://matthewwild.co.uk/projects/luaexpat/luaexpat-${version}.tar.gz"; 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 { luafilesystem = buildLuaPackage rec {
name = "filesystem-1.6.2"; version = "1.6.3";
name = "filesystem-${version}";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "keplerproject"; owner = "keplerproject";
repo = "luafilesystem"; repo = "luafilesystem";
rev = "v1_6_2"; rev = "v${stdenv.lib.replaceChars ["."] ["_"] version}";
sha256 = "134azkxw84xp9g5qmzjsmcva629jm7plwcmjxkdzdg05vyd7kig1"; sha256 = "1hxcnqj53540ysyw8fzax7f09pl98b8f55s712gsglcdxp2g2pri";
}; };
preConfigure = '' preConfigure = ''
@ -224,12 +281,12 @@ let
}; };
lpty = buildLuaPackage rec { lpty = buildLuaPackage rec {
version = "1.2.1";
name = "lpty-${version}"; name = "lpty-${version}";
version = "1.1.1";
src = fetchurl { src = fetchurl {
url = "http://www.tset.de/downloads/lpty-1.1-1.tar.gz"; url = "http://www.tset.de/downloads/lpty-${version}-1.tar.gz";
sha256 = "0d4ffda654dcf37dd8c99bcd100d0ee0dde7782cbd0ba9200ef8711c5cab02f1"; sha256 = "0rgvbpymcgdkzdwfag607xfscs9xyqxg0dj0qr5fv906mi183gs6";
}; };
preBuild = '' preBuild = ''
@ -331,6 +388,8 @@ let
); );
''; '';
installTargets = [ "install" "install-unix" ];
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Network support for Lua"; description = "Network support for Lua";
homepage = "http://w3.impa.br/~diego/software/luasocket/"; homepage = "http://w3.impa.br/~diego/software/luasocket/";