1 { pkgs, lib, config, inputs, hosts, ipv4, ... }:
3 inherit (config.services) prosody;
4 inherit (hosts.mermet.config.services) coturn;
5 domain = config.networking.domain;
11 networking.nftables.ruleset = ''
14 tcp dport { xmpp-client, xmpp-server } counter accept comment "prosody: XMPP"
15 tcp dport 5000 counter accept comment "prosody: XMPP XEP-0065 File Transfer Proxy"
16 tcp dport {${lib.concatMapStringsSep "," toString prosody.httpsPorts}} counter accept comment "prosody: HTTPS"
19 skuid ${prosody.user} counter accept comment "prosody"
24 services.upnpc.redirections =
26 { description = "XMPP";
27 externalPort = 5222; protocol = "TCP";
29 service.wantedBy = ["prosody.service"];
30 service.partOf = ["prosody.service"];
32 { description = "XMPP";
33 externalPort = 5269; protocol = "TCP";
35 service.wantedBy = ["prosody.service"];
36 service.partOf = ["prosody.service"];
38 { description = "XMPP-FTP";
39 externalPort = 5000; protocol = "TCP";
41 service.wantedBy = ["prosody.service"];
42 service.partOf = ["prosody.service"];
44 ] ++ map (externalPort: {
45 description = "XMPP-HTTPS";
46 inherit externalPort; protocol="TCP";
48 service.wantedBy = ["prosody.service"];
49 service.partOf = ["prosody.service"];
50 }) prosody.httpsPorts;
53 services.tor.relay.hiddenServices."${domain}/xmpp".map = [ 5222 5269 5000 ] ++ prosody.httpsPorts;
55 users.groups.acme.members = [ prosody.user ];
56 security.acme.certs."${domain}" = {
57 postRun = "systemctl restart prosody";
59 fileSystems."/var/lib/prosody" = {
60 device = "rpool/var/prosody";
63 services.sanoid.datasets = {
64 "rpool/var/prosody" = {
65 use_template = [ "snap" ];
69 systemd.services.prosody = {
70 wants = [ "acme-selfsigned-${domain}.service" "acme-${domain}.service"];
71 after = [ "acme-selfsigned-${domain}.service" ];
73 # sudo -u prosody prosodyctl check
76 xmppComplianceSuite = true;
80 cloud_notify = false; # not encrypted even with OMEMO
81 #cloud_notify_encrypted = true;
85 server_contact_info = true;
86 watchregistrations = true;
104 -- Listen only in IPv4 until hosting provider's IPv6 works well.
105 interfaces = { "0.0.0.0" }
106 c2s_interfaces = { "0.0.0.0" }
108 --abuse = { "mailto:abuse@${domain}", "xmpp:abuse@${domain}" };
109 --admin = { "mailto:admin@${domain}", "xmpp:admin@${domain}" };
110 --feedback = { "http://${domain}/feedback.php", "mailto:feedback@${domain}", "xmpp:feedback@${domain}" };
111 --sales = { "xmpp:bard@${domain}" };
112 --security = { "xmpp:security@${domain}" };
113 --support = { "http://${domain}/support.php", "xmpp:support@${domain}" };
115 legacy_ssl_ports = { 5222 }
117 -- turncredentials_host = "turn.${domain}"
118 -- turncredentials_port = 3478
119 -- turncredentials_secret = "${lib.removeSuffix "\n" (builtins.readFile (inputs.secrets + "/coturn/static-auth-secret"))}";
121 turn_external_secret = "${lib.removeSuffix "\n" (builtins.readFile (inputs.secrets + "/coturn/static-auth-secret"))}"
122 turn_external_host = "turn.${domain}"
123 turn_external_port = 3478
124 turn_external_ttl = 86400
126 smacks_enabled_s2s = true;
127 smacks_s2s_resend = true;
129 --http_files_dir = "/var/lib/prosody/files"
130 --http_external_url = "https://tmp.${domain}:5281"
131 --https_certificate = "/var/lib/acme/${domain}/fullchain.pem"
132 --https_key = "/var/lib/acme/${domain}/key.pem"
133 --certificates = "/var/lib/acme"
136 Component "proxy65.${domain}" "proxy65"
137 proxy65_address = "proxy65.${domain}"
138 proxy65_acl = { "${domain}" }
140 Component "biboumi.${domain}"
141 component_secret = "useless-secret-on-loopback"
144 domain = "tmp.${domain}";
145 size_limit = 16*1024*1024; # 16 MiB
146 daily_quota = 100*1024*1024; # 100 MiB per day per user
147 global_quota = 1024*1024*1024; # 1 GiB total
151 c2sRequireEncryption = true;
152 s2sRequireEncryption = true;
153 s2sSecureAuth = true;
156 domain = "salons.${domain}";
158 restrict_room_creation = "local"
159 max_history_messages = 42
160 muc_room_locking = true
161 muc_room_lock_timeout = 600
162 muc_tombstones = true
163 muc_tombstone_expiry = 31 * 24 * 60 * 60
164 muc_room_default_public = true
165 muc_room_default_members_only = false
166 muc_room_default_moderated = true
167 muc_room_default_public_jids = false
168 muc_room_default_change_subject = true
169 muc_room_default_history_length = 42
170 muc_room_default_language = "fr"
174 ssl.key = "/var/lib/acme/${domain}/key.pem";
175 ssl.cert = "/var/lib/acme/${domain}/fullchain.pem";
179 virtualHosts."${domain}" = {
181 domain = "${domain}";
182 ssl.key = "/var/lib/acme/${domain}/key.pem";
183 ssl.cert = "/var/lib/acme/${domain}/fullchain.pem";
185 allowRegistration = false;
186 authentication = "internal_hashed";
190 { url = "biboumi.${domain}";
191 description = "Passerelle vers des serveurs IRC (Internet Relay Chat)"; }
193 package = pkgs.prosody.override {
194 withCommunityModules = [