Merge pull request #31006 from florianjacob/prosody

Improvements for Prosody

Changed files
+143 -42
nixos
modules
services
networking
pkgs
development
interpreters
servers
xmpp
prosody
top-level
+55 -21
nixos/modules/services/networking/prosody.nix
···
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 = { ... }: {
···
};
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";
};
···
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";
};
···
modules = moduleOpts;
extraModules = mkOption {
+
type = types.listOf types.str;
+
default = [];
description = "Enable custom modules";
-
default = [];
};
virtualHosts = mkOption {
···
};
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";
+
type = types.listOf types.str;
+
default = [];
example = [ "admin1@example.com" "admin2@example.com" ];
-
default = [];
+
description = "List of administrators of the current host";
};
extraConfig = mkOption {
type = types.lines;
-
default = '''';
+
default = "";
description = "Additional prosody configuration";
};
···
};
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";
};
-
};
};
+1 -1
pkgs/development/interpreters/lua-5/filesystem.nix
···
meta = {
homepage = https://github.com/keplerproject/luafilesystem;
hydraPlatforms = stdenv.lib.platforms.linux;
-
maintainers = [ stdenv.lib.maintainers.flosse ];
+
maintainers = [ ];
};
}
+19 -11
pkgs/servers/xmpp/prosody/default.nix
···
{ 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";
···
};
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"
···
];
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};'
···
license = licenses.mit;
homepage = http://www.prosody.im;
platforms = platforms.linux;
-
maintainers = [ maintainers.flosse ];
+
maintainers = [ ];
};
}
+1 -1
pkgs/top-level/all-packages.nix
···
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 { };
+67 -8
pkgs/top-level/lua-packages.nix
···
{ 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
}:
···
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; [ ];
};
};
···
};
};
+
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}";
···
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";
···
};
};
+
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 = ''
···
};
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 = ''
···
prefix=$out
);
'';
+
+
installTargets = [ "install" "install-unix" ];
meta = with stdenv.lib; {
description = "Network support for Lua";