1 { stdenv, fetchurl, lib, libidn, openssl, makeWrapper, fetchhg, buildPackages
6 # use withExtraLibs to add additional dependencies of community modules
8 , withExtraLuaPackages ? _: [ ]
9 , withOnlyInstalledCommunityModules ? [ ]
10 , withCommunityModules ? [ ] }:
15 luaEnv = lua.withPackages(p: with p; [
16 luasocket luasec luaexpat luafilesystem luabitop luadbi-sqlite3 luaunbound
18 ++ lib.optional withDBI p.luadbi
19 ++ withExtraLuaPackages p
22 stdenv.mkDerivation rec {
23 version = "0.12.4"; # also update communityModules
25 # The following community modules are necessary for the nixos module
26 # prosody module to comply with XEP-0423 and provide a working
34 url = "https://prosody.im/downloads/source/${pname}-${version}.tar.gz";
35 sha256 = "R9cSJzwvKVWMQS9s2uwHMmC7wmt92iQ9tYAzAYPWWFY=";
38 # A note to all those merging automated updates: Please also update this
39 # attribute as some modules might not be compatible with a newer prosody
41 communityModules = fetchhg {
42 url = "https://hg.prosody.im/prosody-modules";
44 hash = "sha256-N1vmShDWtWsHD4b1x7UjX6Sj28iPaDeCLSYeDOLLhzo=";
47 nativeBuildInputs = [ makeWrapper ];
49 luaEnv libidn openssl icu
55 "--with-lua-bin=${lib.getBin buildPackages.lua}/bin"
56 "--with-lua-include=${luaEnv}/include"
57 "--with-lua=${luaEnv}"
58 "--c-compiler=${stdenv.cc.targetPrefix}cc"
59 "--linker=${stdenv.cc.targetPrefix}cc"
61 configurePlatforms = [];
64 make -C tools/migration
67 # the wrapping should go away once lua hook is fixed
69 ${concatMapStringsSep "\n" (module: ''
70 cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
71 '') (lib.lists.unique(nixosModuleDeps ++ withCommunityModules ++ withOnlyInstalledCommunityModules))}
72 wrapProgram $out/bin/prosodyctl \
73 --add-flags '--config "/etc/prosody/prosody.cfg.lua"'
74 make -C tools/migration install
78 communityModules = withCommunityModules;
79 tests = { inherit (nixosTests) prosody prosody-mysql; };
83 description = "Open-source XMPP application server written in Lua";
84 license = licenses.mit;
85 homepage = "https://prosody.im";
86 platforms = platforms.linux;
87 maintainers = with maintainers; [ toastal ];