Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 stdenv,
3 fetchurl,
4 lib,
5 libidn,
6 openssl,
7 makeWrapper,
8 fetchhg,
9 buildPackages,
10 icu,
11 lua,
12 nixosTests,
13 withDBI ? true,
14 # use withExtraLibs to add additional dependencies of community modules
15 withExtraLibs ? [ ],
16 withExtraLuaPackages ? _: [ ],
17 withOnlyInstalledCommunityModules ? [ ],
18 withCommunityModules ? [ ],
19}:
20
21let
22 luaEnv = lua.withPackages (
23 p:
24 with p;
25 [
26 luasocket
27 luasec
28 luaexpat
29 luafilesystem
30 luabitop
31 luadbi-sqlite3
32 luaunbound
33 ]
34 ++ lib.optional withDBI p.luadbi
35 ++ withExtraLuaPackages p
36 );
37in
38stdenv.mkDerivation rec {
39 version = "0.12.5"; # also update communityModules
40 pname = "prosody";
41 # The following community modules are necessary for the nixos module
42 # prosody module to comply with XEP-0423 and provide a working
43 # default setup.
44 nixosModuleDeps = [
45 "cloud_notify"
46 "vcard_muc"
47 "http_upload"
48 ];
49 src = fetchurl {
50 url = "https://prosody.im/downloads/source/${pname}-${version}.tar.gz";
51 sha256 = "sha256-d4+3cHoPEDmVlbp6ucZt0qIojArjp/5Kt4+X1GK9OZ8=";
52 };
53
54 # A note to all those merging automated updates: Please also update this
55 # attribute as some modules might not be compatible with a newer prosody
56 # version.
57 communityModules = fetchhg {
58 url = "https://hg.prosody.im/prosody-modules";
59 rev = "fc521fb5ffa0";
60 hash = "sha256-Ci52Xkx1xd3GW9lBPKgWFBB52SocxKyj8f/Hq3hZeak=";
61 };
62
63 nativeBuildInputs = [ makeWrapper ];
64 buildInputs = [
65 luaEnv
66 libidn
67 openssl
68 icu
69 ]
70 ++ withExtraLibs;
71
72 configureFlags = [
73 "--ostype=linux"
74 "--with-lua-bin=${lib.getBin buildPackages.lua}/bin"
75 "--with-lua-include=${luaEnv}/include"
76 "--with-lua=${luaEnv}"
77 "--c-compiler=${stdenv.cc.targetPrefix}cc"
78 "--linker=${stdenv.cc.targetPrefix}cc"
79 ];
80 configurePlatforms = [ ];
81
82 postBuild = ''
83 make -C tools/migration
84 '';
85
86 buildFlags = [
87 # don't search for configs in the nix store when running prosodyctl
88 "INSTALLEDCONFIG=/etc/prosody"
89 "INSTALLEDDATA=/var/lib/prosody"
90 ];
91
92 # the wrapping should go away once lua hook is fixed
93 postInstall = ''
94 ${lib.concatMapStringsSep "\n"
95 (module: ''
96 cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
97 '')
98 (lib.lists.unique (nixosModuleDeps ++ withCommunityModules ++ withOnlyInstalledCommunityModules))
99 }
100 make -C tools/migration install
101 '';
102
103 passthru = {
104 communityModules = withCommunityModules;
105 tests = { inherit (nixosTests) prosody prosody-mysql; };
106 };
107
108 meta = with lib; {
109 description = "Open-source XMPP application server written in Lua";
110 license = licenses.mit;
111 homepage = "https://prosody.im";
112 platforms = platforms.linux;
113 maintainers = with maintainers; [ toastal ];
114 };
115}