]> Git — Sourcephile - sourcephile-nix.git/blob - machines/losurdo/prosody.nix
knot: fix serial and gandi IPv6
[sourcephile-nix.git] / machines / losurdo / prosody.nix
1 { pkgs, lib, config, machines, ipv4, ... }:
2 let
3 inherit (config) networking;
4 inherit (config.services) prosody;
5 inherit (machines.mermet.config.services) coturn;
6 in
7 {
8 imports = [
9 prosody/biboumi.nix
10 #../../sec/machines/losurdo/prosody.nix
11 ];
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"
17 '';
18 services.tor.hiddenServices."${networking.domain}/xmpp".map = [
19 { port = 5222; }
20 { port = 5269; }
21 { port = 5000; }
22 ] ++ map (port: {inherit port;}) prosody.httpsPorts;
23 users.groups.acme.members = [ prosody.user ];
24 security.acme.certs."${networking.domain}" = {
25 postRun = "systemctl reload prosody";
26 };
27 systemd.services.prosody = {
28 wants = [ "acme-selfsigned-${networking.domain}.service" "acme-${networking.domain}.service"];
29 after = [ "acme-selfsigned-${networking.domain}.service" ];
30 };
31 # sudo -u prosody prosodyctl check
32 services.prosody = {
33 enable = true;
34 xmppComplianceSuite = true;
35 modules = {
36 announce = true;
37 blocklist = true;
38 cloud_notify = true;
39 groups = true;
40 limits = false;
41 motd = true;
42 server_contact_info = true;
43 watchregistrations = true;
44 websocket = false;
45 welcome = true;
46 proxy65 = false;
47 };
48 extraModules = [
49 "turncredentials"
50 #"net_multiplex"
51 #"extdisco"
52 ];
53 extraConfig = ''
54 -- Listen only in IPv4 until hosting provider's IPv6 works well.
55 interfaces = { "0.0.0.0" }
56 c2s_interfaces = { "0.0.0.0" }
57 contact_info = {
58 --abuse = { "mailto:abuse@${networking.domain}", "xmpp:abuse@${networking.domain}" };
59 --admin = { "mailto:admin@${networking.domain}", "xmpp:admin@${networking.domain}" };
60 --feedback = { "http://${networking.domain}/feedback.php", "mailto:feedback@${networking.domain}", "xmpp:feedback@${networking.domain}" };
61 --sales = { "xmpp:bard@${networking.domain}" };
62 --security = { "xmpp:security@${networking.domain}" };
63 --support = { "http://${networking.domain}/support.php", "xmpp:support@${networking.domain}" };
64 }
65 legacy_ssl_ports = { 5222 }
66
67 turncredentials_host = "turn.${networking.domain}"
68 turncredentials_port = 3478
69
70 --http_files_dir = "/var/lib/prosody/files"
71 --http_external_url = "https://tmp.${networking.domain}:5281"
72 --https_certificate = "/var/lib/acme/${networking.domain}/fullchain.pem"
73 --https_key = "/var/lib/acme/${networking.domain}/key.pem"
74 --certificates = "/var/lib/acme"
75
76 proxy65_ports = 5000
77 Component "proxy65.${networking.domain}" "proxy65"
78 proxy65_address = "proxy65.${networking.domain}"
79 proxy65_acl = { "${networking.domain}" }
80
81 Component "biboumi.${networking.domain}"
82 component_secret = "useless-secret-on-loopback"
83 '';
84 #ports = {80};
85 #ssl_ports = {443};
86 c2sRequireEncryption = true;
87 s2sRequireEncryption = true;
88 s2sSecureAuth = true;
89 uploadHttp = {
90 domain = "tmp.${networking.domain}";
91 # Prosody's HTTP parser limit on body size
92 uploadFileSizeLimit = "10485760";
93 userQuota = 100 * 1024 * 1024;
94 uploadExpireAfter = "60 * 60 * 24 * 7";
95 httpUploadPath = "/var/lib/prosody/upload";
96 };
97 muc = [
98 { domain = "salons.${networking.domain}";
99 extraConfig = ''
100 restrict_room_creation = "local"
101 max_history_messages = 42
102 muc_room_locking = true
103 muc_room_lock_timeout = 600
104 muc_tombstones = true
105 muc_tombstone_expiry = 31 * 24 * 60 * 60
106 muc_room_default_public = true
107 muc_room_default_members_only = false
108 muc_room_default_moderated = true
109 muc_room_default_public_jids = false
110 muc_room_default_change_subject = true
111 muc_room_default_history_length = 42
112 muc_room_default_language = "fr"
113 '';
114 }
115 ];
116 ssl.key = "/var/lib/acme/${networking.domain}/key.pem";
117 ssl.cert = "/var/lib/acme/${networking.domain}/fullchain.pem";
118 admins = [
119 "julm@${networking.domain}"
120 ];
121 virtualHosts."${networking.domain}" = {
122 enabled = true;
123 domain = "${networking.domain}";
124 ssl.key = "/var/lib/acme/${networking.domain}/key.pem";
125 ssl.cert = "/var/lib/acme/${networking.domain}/fullchain.pem";
126 };
127 allowRegistration = false;
128 authentication = "internal_hashed";
129 httpPorts = [];
130 httpsPorts = [5281];
131 disco_items = [
132 { url = "biboumi.${networking.domain}";
133 description = "Passerelle vers des serveurs IRC (Internet Relay Chat)"; }
134 ];
135 package = pkgs.prosody.override {
136 withCommunityModules = [
137 "turncredentials"
138 #"extdisco"
139 ];
140 };
141 };
142 }