1 { pkgs, lib, config, machines, ipv4, ... }:
3 inherit (builtins.extraBuiltins) pass-chomp;
4 inherit (config) networking;
5 inherit (config.services) prosody;
6 inherit (machines.mermet.config.services) coturn;
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 users.groups.acme.members = [ prosody.user ];
19 security.acme.certs."${networking.domain}" = {
20 postRun = "systemctl reload prosody";
22 systemd.services.prosody = {
23 wants = [ "acme-selfsigned-${networking.domain}.service" "acme-${networking.domain}.service"];
24 after = [ "acme-selfsigned-${networking.domain}.service" ];
26 # sudo -u prosody prosodyctl check
29 xmppComplianceSuite = true;
37 watchregistrations = true;
48 -- Listen only in IPv4 until hosting provider's IPv6 works well.
49 interfaces = { "0.0.0.0" }
50 c2s_interfaces = { "0.0.0.0" }
52 turncredentials_host = "turn.${networking.domain}"
53 turncredentials_secret = "${pass-chomp "machines/mermet/coturn/static-auth-secret"}"
54 turncredentials_port = 3478
56 --external_services = {
57 -- ["turn.${networking.domain}"] = {
60 -- port="${toString coturn.alt-listening-port}";
62 -- ["turn.${networking.domain}"] = {
65 -- port="${toString coturn.listening-port}";
66 -- username="xmpp-user";
67 -- password="base64.encode(hmac_sha1(\"${pass-chomp "machines/mermet/coturn/static-auth-secret"}\", "xmpp-user", false))";
71 --http_files_dir = "/var/lib/prosody/files"
72 --http_external_url = "https://tmp.${networking.domain}:5281"
73 --https_certificate = "/var/lib/acme/${networking.domain}/fullchain.pem"
74 --https_key = "/var/lib/acme/${networking.domain}/key.pem"
75 --certificates = "/var/lib/acme"
78 Component "proxy65.${networking.domain}" "proxy65"
79 proxy65_address = "proxy65.${networking.domain}"
80 proxy65_acl = { "${networking.domain}" }
82 Component "biboumi.${networking.domain}"
83 component_secret = "useless-secret-on-loopback"
87 c2sRequireEncryption = true;
88 s2sRequireEncryption = true;
91 domain = "tmp.${networking.domain}";
92 # Prosody's HTTP parser limit on body size
93 uploadFileSizeLimit = "10485760";
94 userQuota = 100 * 1024 * 1024;
95 uploadExpireAfter = "60 * 60 * 24 * 7";
96 httpUploadPath = "/var/lib/prosody/upload";
99 { domain = "salons.${networking.domain}";
101 restrict_room_creation = "local"
102 max_history_messages = 42
103 muc_room_locking = true
104 muc_room_lock_timeout = 600
105 muc_tombstones = true
106 muc_tombstone_expiry = 31 * 24 * 60 * 60
107 muc_room_default_public = true
108 muc_room_default_members_only = false
109 muc_room_default_moderated = true
110 muc_room_default_public_jids = false
111 muc_room_default_change_subject = true
112 muc_room_default_history_length = 42
113 muc_room_default_language = "fr"
117 ssl.key = "/var/lib/acme/${networking.domain}/key.pem";
118 ssl.cert = "/var/lib/acme/${networking.domain}/fullchain.pem";
120 "julm@${networking.domain}"
122 virtualHosts."${networking.domain}" = {
124 domain = "${networking.domain}";
125 ssl.key = "/var/lib/acme/${networking.domain}/key.pem";
126 ssl.cert = "/var/lib/acme/${networking.domain}/fullchain.pem";
128 allowRegistration = false;
129 authentication = "internal_hashed";
133 { url = "biboumi.${networking.domain}";
134 description = "Passerelle vers des serveurs IRC (Internet Relay Chat)"; }
136 package = pkgs.prosody.override {
137 withCommunityModules = [