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