blob: 9f0ade2bd1bdccf5d9f9a7c5a318bae83b69409a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
{ options, config, lib, namespace, pkgs, ... }:
with lib; with lib.${namespace}; let
cfg = config.${namespace}.services.matrix;
impermanence = config.${namespace}.system.impermanence;
in {
options.${namespace}.services.matrix = with types; {
enable = mkEnableOption "matrix server (continuwuity)";
host = mkOption {
type = str;
};
};
config = mkIf cfg.enable {
cxl.services.web.enable = true;
environment.persistence.${impermanence.location} = {
directories = [
"/var/lib/private/continuwuity"
];
};
services.matrix-continuwuity = {
enable = true;
settings = {
global = {
server_name = cfg.host;
};
};
};
networking = {
firewall = {
allowedTCPPorts = [ 8448 ];
};
};
services.nginx = {
enable = true;
virtualHosts = {
"${cfg.host}" = {
addSSL = true;
extraConfig = ''
listen 8448 ssl;
listen [::]:8448 ssl;
'';
locations = {
"/_matrix/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:6167";
};
"/.well-known/matrix/client" = {
extraConfig = ''
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '{"m.homeserver": {"base_url": "https://${cfg.host}:8448"}}';
'';
};
"/.well-known/matrix/server" = {
extraConfig = ''
default_type application/json;
return 200 '{"m.server": "${cfg.host}:8448"}';
'';
};
};
};
};
};
};
}
|