nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 (finalAttrs: {
39 pname = "prosody";
40 version = "13.0.3"; # also update communityModules
41
42 src = fetchurl {
43 url = "https://prosody.im/downloads/source/prosody-${finalAttrs.version}.tar.gz";
44 hash = "sha256-pR7T6+VMGazWOO5fVAFKs2lsEvmf/HWsKT1p8vD/3As=";
45 };
46
47 # The following community modules are necessary for the nixos module
48 # prosody module to comply with XEP-0423 and provide a working
49 # default setup.
50 nixosModuleDeps = [
51 "cloud_notify"
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 = "83355cfcad1d";
60 hash = "sha256-v8o2FMUY2dQEQ+G81Ec4RJ7J5Mz5CkXc4iabAAb13L4=";
61 };
62
63 nativeBuildInputs = [ makeWrapper ];
64
65 buildInputs = [
66 luaEnv
67 libidn
68 openssl
69 icu
70 ]
71 ++ withExtraLibs;
72
73 configureFlags = [
74 "--ostype=linux"
75 "--with-lua-bin=${lib.getBin buildPackages.lua}/bin"
76 "--with-lua-include=${luaEnv}/include"
77 "--with-lua=${luaEnv}"
78 "--c-compiler=${stdenv.cc.targetPrefix}cc"
79 "--linker=${stdenv.cc.targetPrefix}cc"
80 ];
81
82 configurePlatforms = [ ];
83
84 postBuild = ''
85 make -C tools/migration
86 '';
87
88 buildFlags = [
89 # don't search for configs in the nix store when running prosodyctl
90 "INSTALLEDCONFIG=/etc/prosody"
91 "INSTALLEDDATA=/var/lib/prosody"
92 ];
93
94 # the wrapping should go away once lua hook is fixed
95 postInstall = ''
96 ${lib.concatMapStringsSep "\n"
97 (module: ''
98 cp -r ${finalAttrs.communityModules}/mod_${module} $out/lib/prosody/modules/
99 '')
100 (
101 lib.lists.unique (
102 finalAttrs.nixosModuleDeps ++ withCommunityModules ++ withOnlyInstalledCommunityModules
103 )
104 )
105 }
106 make -C tools/migration install
107 '';
108
109 passthru = {
110 communityModules = withCommunityModules;
111 tests = { inherit (nixosTests) prosody prosody-mysql; };
112 };
113
114 meta = {
115 description = "Open-source XMPP application server written in Lua";
116 license = lib.licenses.mit;
117 changelog = "https://prosody.im/doc/release/${finalAttrs.version}";
118 homepage = "https://prosody.im";
119 platforms = lib.platforms.linux;
120 mainProgram = "prosody";
121 maintainers = with lib.maintainers; [
122 toastal
123 mirror230469
124 SuperSandro2000
125 ];
126 };
127})