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 = ''
12 add rule inet filter net2fw tcp dport {5222,5269} counter accept comment "XMPP"
13 add rule inet filter net2fw tcp dport 5000 counter accept comment "XMPP XEP-0065 File Transfer Proxy"
14 add rule inet filter net2fw tcp dport {${lib.concatMapStringsSep "," toString prosody.httpsPorts}} counter accept comment "XMPP HTTPS"
15 add rule inet filter fw2net meta skuid ${prosody.user} counter accept comment "Prosody"
18 services.upnpc.redirections =
20 { description = "XMPP";
21 externalPort = 5222; protocol = "TCP";
23 service.wantedBy = ["prosody.service"];
24 service.partOf = ["prosody.service"];
26 { description = "XMPP";
27 externalPort = 5269; protocol = "TCP";
29 service.wantedBy = ["prosody.service"];
30 service.partOf = ["prosody.service"];
32 { description = "XMPP-FTP";
33 externalPort = 5000; protocol = "TCP";
35 service.wantedBy = ["prosody.service"];
36 service.partOf = ["prosody.service"];
38 ] ++ map (externalPort: {
39 description = "XMPP-HTTPS";
40 inherit externalPort; protocol="TCP";
42 service.wantedBy = ["prosody.service"];
43 service.partOf = ["prosody.service"];
44 }) prosody.httpsPorts;
47 services.tor.relay.hiddenServices."${domain}/xmpp".map = [ 5222 5269 5000 ] ++ prosody.httpsPorts;
49 users.groups.acme.members = [ prosody.user ];
50 security.acme.certs."${domain}" = {
51 postRun = "systemctl restart prosody";
53 fileSystems."/var/lib/prosody" = {
54 device = "rpool/var/prosody";
57 services.sanoid.datasets = {
58 "rpool/var/prosody" = {
59 use_template = [ "snap" ];
63 systemd.services.prosody = {
64 wants = [ "acme-selfsigned-${domain}.service" "acme-${domain}.service"];
65 after = [ "acme-selfsigned-${domain}.service" ];
67 # sudo -u prosody prosodyctl check
70 xmppComplianceSuite = true;
78 server_contact_info = true;
79 watchregistrations = true;
97 -- Listen only in IPv4 until hosting provider's IPv6 works well.
98 interfaces = { "0.0.0.0" }
99 c2s_interfaces = { "0.0.0.0" }
101 --abuse = { "mailto:abuse@${domain}", "xmpp:abuse@${domain}" };
102 --admin = { "mailto:admin@${domain}", "xmpp:admin@${domain}" };
103 --feedback = { "http://${domain}/feedback.php", "mailto:feedback@${domain}", "xmpp:feedback@${domain}" };
104 --sales = { "xmpp:bard@${domain}" };
105 --security = { "xmpp:security@${domain}" };
106 --support = { "http://${domain}/support.php", "xmpp:support@${domain}" };
108 legacy_ssl_ports = { 5222 }
110 turncredentials_host = "turn.${domain}"
111 turncredentials_port = 3478
112 turncredentials_secret = "${lib.removeSuffix "\n" (builtins.readFile (inputs.secrets + "/coturn/static-auth-secret"))}";
114 turn_external_secret = "${lib.removeSuffix "\n" (builtins.readFile (inputs.secrets + "/coturn/static-auth-secret"))}"
115 turn_external_host = ""turn.${domain}"
116 turn_external_port = 3478
117 turn_external_ttl = 86400
119 smacks_enabled_s2s = true;
120 smacks_s2s_resend = true;
122 --http_files_dir = "/var/lib/prosody/files"
123 --http_external_url = "https://tmp.${domain}:5281"
124 --https_certificate = "/var/lib/acme/${domain}/fullchain.pem"
125 --https_key = "/var/lib/acme/${domain}/key.pem"
126 --certificates = "/var/lib/acme"
129 Component "proxy65.${domain}" "proxy65"
130 proxy65_address = "proxy65.${domain}"
131 proxy65_acl = { "${domain}" }
133 Component "biboumi.${domain}"
134 component_secret = "useless-secret-on-loopback"
136 Component "tmp.${domain}" "http_file_share"
137 http_file_share_size_limit = 16*1024*1024 -- 16 MiB
138 http_file_share_daily_quota = 100*1024*1024 -- 100 MiB per day per user
139 http_file_share_global_quota = 1024*1024*1024 -- 1 GiB total
143 c2sRequireEncryption = true;
144 s2sRequireEncryption = true;
145 s2sSecureAuth = true;
147 domain = "tmp.${domain}";
148 # Prosody's HTTP parser limit on body size
149 uploadFileSizeLimit = "10485760";
150 userQuota = 100 * 1024 * 1024;
151 uploadExpireAfter = "60 * 60 * 24 * 7";
152 httpUploadPath = "/var/lib/prosody/upload";
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 = [