ark/hosts/wolumonde/modules/conduit.nix

51 lines
1.4 KiB
Nix
Raw Normal View History

2022-09-02 17:19:59 +03:00
{
2022-09-02 18:02:46 +03:00
config,
pkgs,
2023-03-16 17:59:13 +03:00
inputs,
2022-09-02 18:02:46 +03:00
...
}: let
_wellKnownFileClient = pkgs.writeText "client" (
builtins.toJSON
2023-07-14 14:29:09 +03:00
{
"m.homeserver"."base_url" = "https://matrix.gaze.systems";
"org.matrix.msc3575.proxy"."url" = "https://matrix.gaze.systems";
}
2022-09-02 18:02:46 +03:00
);
_wellKnownFileServer =
pkgs.writeText "server"
(builtins.toJSON {"m.server" = "matrix.gaze.systems:443";});
wellKnownFiles = pkgs.runCommand "well-known" {} ''
mkdir -p $out
cp ${_wellKnownFileServer} $out/server
cp ${_wellKnownFileClient} $out/client
'';
in {
2022-09-02 17:19:59 +03:00
services.matrix-conduit = {
enable = true;
2023-03-16 17:59:13 +03:00
package = inputs.conduit.packages.${pkgs.system}.default;
2022-09-02 17:19:59 +03:00
settings.global = {
server_name = "gaze.systems";
max_request_size = 1000 * 1000 * 20;
2022-09-02 18:02:46 +03:00
allow_registration = false;
2022-09-02 17:19:59 +03:00
allow_federation = true;
trusted_servers = ["matrix.org" "nixos.dev" "conduit.rs"];
address = "::1";
port = 6167;
2023-07-14 14:29:09 +03:00
database_backend = "rocksdb";
2022-09-02 17:19:59 +03:00
};
};
services.nginx.virtualHosts."matrix.gaze.systems" = {
2023-05-08 23:09:44 +03:00
useACMEHost = "gaze.systems";
2022-09-02 17:19:59 +03:00
forceSSL = true;
2022-09-02 18:02:46 +03:00
locations."/".proxyPass = "http://localhost:${toString config.services.matrix-conduit.settings.global.port}";
2022-09-02 17:19:59 +03:00
};
services.nginx.virtualHosts."gaze.systems" = {
2022-09-02 18:02:46 +03:00
locations."/.well-known/matrix/".extraConfig = ''
add_header content-type application/json;
2022-09-02 18:57:30 +03:00
add_header access-control-allow-origin *;
2022-09-02 18:02:46 +03:00
alias ${wellKnownFiles}/;
2022-09-02 17:19:59 +03:00
'';
};
}