summary refs log tree commit diff
diff options
context:
space:
mode:
authorOrivej Desh <orivej@gmx.fr>2017-12-09 09:19:24 +0000
committerGitHub <noreply@github.com>2017-12-09 09:19:24 +0000
commit40950f6a2d081797957ac26b59655d96d26ff770 (patch)
treea56bb36931530c09a9e1b3dc82e1a1b3e960836d
parenta16501cd449e6dcb232a0779715b1cf1b12ab671 (diff)
parentc84cb83e40b2bac6314d46389fc0478e334c9c2c (diff)
downloadnixlib-40950f6a2d081797957ac26b59655d96d26ff770.tar
nixlib-40950f6a2d081797957ac26b59655d96d26ff770.tar.gz
nixlib-40950f6a2d081797957ac26b59655d96d26ff770.tar.bz2
nixlib-40950f6a2d081797957ac26b59655d96d26ff770.tar.lz
nixlib-40950f6a2d081797957ac26b59655d96d26ff770.tar.xz
nixlib-40950f6a2d081797957ac26b59655d96d26ff770.tar.zst
nixlib-40950f6a2d081797957ac26b59655d96d26ff770.zip
Merge pull request #31006 from florianjacob/prosody
 Improvements for Prosody
-rw-r--r--nixos/modules/services/networking/prosody.nix76
-rw-r--r--pkgs/development/interpreters/lua-5/filesystem.nix2
-rw-r--r--pkgs/servers/xmpp/prosody/default.nix30
-rw-r--r--pkgs/top-level/all-packages.nix2
-rw-r--r--pkgs/top-level/lua-packages.nix75
5 files changed, 143 insertions, 42 deletions
diff --git a/nixos/modules/services/networking/prosody.nix b/nixos/modules/services/networking/prosody.nix
index fb9c9dc67f24..f34d8e172b46 100644
--- a/nixos/modules/services/networking/prosody.nix
+++ b/nixos/modules/services/networking/prosody.nix
@@ -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";
       };
-
     };
 
   };
diff --git a/pkgs/development/interpreters/lua-5/filesystem.nix b/pkgs/development/interpreters/lua-5/filesystem.nix
index 21f656044a33..7aa41e95cc9b 100644
--- a/pkgs/development/interpreters/lua-5/filesystem.nix
+++ b/pkgs/development/interpreters/lua-5/filesystem.nix
@@ -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 = [ ];
   };
 }
diff --git a/pkgs/servers/xmpp/prosody/default.nix b/pkgs/servers/xmpp/prosody/default.nix
index 3285456a3485..b0e3492c0da1 100644
--- a/pkgs/servers/xmpp/prosody/default.nix
+++ b/pkgs/servers/xmpp/prosody/default.nix
@@ -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 = [ ];
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 22d521cabfc5..6ff6ff6dcf7d 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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 { };
diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix
index 47299791e86b..1bceac77f8f4 100644
--- a/pkgs/top-level/lua-packages.nix
+++ b/pkgs/top-level/lua-packages.nix
@@ -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/";