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