1 { pkgs, lib, config, machines, ipv4, ... }:
3 inherit (config) networking;
4 inherit (config.services) prosody;
5 inherit (machines.mermet.config.services) coturn;
10 #../../sec/machines/losurdo/prosody.nix
12 networking.nftables.ruleset = ''
13 add rule inet filter net2fw tcp dport {5222,5269} counter accept comment "XMPP"
14 add rule inet filter net2fw tcp dport 5000 counter accept comment "XMPP XEP-0065 File Transfer Proxy"
15 add rule inet filter net2fw tcp dport {${lib.concatMapStringsSep "," toString prosody.httpsPorts}} counter accept comment "XMPP HTTPS"
16 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;
46 services.tor.relay.hiddenServices."${networking.domain}/xmpp".map = [ 5222 5269 5000 ] ++ prosody.httpsPorts;
48 users.groups.acme.members = [ prosody.user ];
49 security.acme.certs."${networking.domain}" = {
50 postRun = "systemctl reload prosody";
52 systemd.services.prosody = {
53 wants = [ "acme-selfsigned-${networking.domain}.service" "acme-${networking.domain}.service"];
54 after = [ "acme-selfsigned-${networking.domain}.service" ];
56 # sudo -u prosody prosodyctl check
59 xmppComplianceSuite = true;
67 server_contact_info = true;
68 watchregistrations = true;
79 -- Listen only in IPv4 until hosting provider's IPv6 works well.
80 interfaces = { "0.0.0.0" }
81 c2s_interfaces = { "0.0.0.0" }
83 --abuse = { "mailto:abuse@${networking.domain}", "xmpp:abuse@${networking.domain}" };
84 --admin = { "mailto:admin@${networking.domain}", "xmpp:admin@${networking.domain}" };
85 --feedback = { "http://${networking.domain}/feedback.php", "mailto:feedback@${networking.domain}", "xmpp:feedback@${networking.domain}" };
86 --sales = { "xmpp:bard@${networking.domain}" };
87 --security = { "xmpp:security@${networking.domain}" };
88 --support = { "http://${networking.domain}/support.php", "xmpp:support@${networking.domain}" };
90 legacy_ssl_ports = { 5222 }
92 turncredentials_host = "turn.${networking.domain}"
93 turncredentials_port = 3478
95 --http_files_dir = "/var/lib/prosody/files"
96 --http_external_url = "https://tmp.${networking.domain}:5281"
97 --https_certificate = "/var/lib/acme/${networking.domain}/fullchain.pem"
98 --https_key = "/var/lib/acme/${networking.domain}/key.pem"
99 --certificates = "/var/lib/acme"
102 Component "proxy65.${networking.domain}" "proxy65"
103 proxy65_address = "proxy65.${networking.domain}"
104 proxy65_acl = { "${networking.domain}" }
106 Component "biboumi.${networking.domain}"
107 component_secret = "useless-secret-on-loopback"
111 c2sRequireEncryption = true;
112 s2sRequireEncryption = true;
113 s2sSecureAuth = true;
115 domain = "tmp.${networking.domain}";
116 # Prosody's HTTP parser limit on body size
117 uploadFileSizeLimit = "10485760";
118 userQuota = 100 * 1024 * 1024;
119 uploadExpireAfter = "60 * 60 * 24 * 7";
120 httpUploadPath = "/var/lib/prosody/upload";
123 { domain = "salons.${networking.domain}";
125 restrict_room_creation = "local"
126 max_history_messages = 42
127 muc_room_locking = true
128 muc_room_lock_timeout = 600
129 muc_tombstones = true
130 muc_tombstone_expiry = 31 * 24 * 60 * 60
131 muc_room_default_public = true
132 muc_room_default_members_only = false
133 muc_room_default_moderated = true
134 muc_room_default_public_jids = false
135 muc_room_default_change_subject = true
136 muc_room_default_history_length = 42
137 muc_room_default_language = "fr"
141 ssl.key = "/var/lib/acme/${networking.domain}/key.pem";
142 ssl.cert = "/var/lib/acme/${networking.domain}/fullchain.pem";
144 "julm@${networking.domain}"
146 virtualHosts."${networking.domain}" = {
148 domain = "${networking.domain}";
149 ssl.key = "/var/lib/acme/${networking.domain}/key.pem";
150 ssl.cert = "/var/lib/acme/${networking.domain}/fullchain.pem";
152 allowRegistration = false;
153 authentication = "internal_hashed";
157 { url = "biboumi.${networking.domain}";
158 description = "Passerelle vers des serveurs IRC (Internet Relay Chat)"; }
160 package = pkgs.prosody.override {
161 withCommunityModules = [