diff options
author | Azat Bahawi <azat@bahawi.net> | 2024-02-20 00:53:48 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2024-02-20 00:53:48 +0300 |
commit | d907b7b8f0aecee0f9eba12b09b929d720d07a8d (patch) | |
tree | 4f6bbbe605ebf96e1aefbc657dc975208b2436d1 /modules/nixos/matrix | |
parent | 2024-02-11 (diff) |
2024-02-20
Diffstat (limited to '')
-rw-r--r-- | modules/nixos/matrix/default.nix | 1 | ||||
-rw-r--r-- | modules/nixos/matrix/synapse.nix | 92 |
2 files changed, 0 insertions, 93 deletions
diff --git a/modules/nixos/matrix/default.nix b/modules/nixos/matrix/default.nix index 879243e..e7d5a02 100644 --- a/modules/nixos/matrix/default.nix +++ b/modules/nixos/matrix/default.nix @@ -2,6 +2,5 @@ _: { imports = [ ./dendrite.nix ./element.nix - ./synapse.nix ]; } diff --git a/modules/nixos/matrix/synapse.nix b/modules/nixos/matrix/synapse.nix deleted file mode 100644 index 02592de..0000000 --- a/modules/nixos/matrix/synapse.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ - config, - lib, - ... -}: -with lib; let - cfg = config.nixfiles.modules.matrix.synapse; -in { - options.nixfiles.modules.matrix.synapse = { - enable = mkEnableOption "Synapse Matrix server"; - - domain = mkOption { - description = "Domain name sans protocol scheme."; - type = with types; str; - default = config.networking.domain; - }; - }; - - config = let - bind_address = "127.0.0.1"; - port = 8448; - in - mkIf cfg.enable { - ark.directories = ["/var/lib/matrix-synapse"]; - - nixfiles.modules = { - nginx = { - enable = true; - upstreams.synapse.servers."${bind_address}:${toString port}" = {}; - virtualHosts.${cfg.domain}.locations = { - "~ ^(/_matrix|/_synapse/client)".proxyPass = "http://synapse"; - "= /.well-known/matrix/server" = { - extraConfig = '' - add_header Content-Type application/json; - ''; - return = "200 '${generators.toJSON {} { - "m.server" = "${cfg.domain}:443"; - }}'"; - }; - "= /.well-known/matrix/client" = { - extraConfig = '' - add_header Content-Type application/json; - add_header Access-Control-Allow-Origin *; - ''; - return = "200 '${generators.toJSON {} { - "m.homeserver".base_url = "https://${cfg.domain}"; - }}'"; - }; - }; - }; - postgresql.enable = true; - }; - - services = let - db = "synapse"; - in { - matrix-synapse = { - enable = true; - server_name = config.networking.domain; - - database_type = "psycopg2"; - database_name = db; - database_user = db; - - listeners = [ - { - inherit bind_address port; - type = "http"; - tls = false; - x_forwarded = true; - resources = [ - { - names = ["client" "federation"]; - compress = false; - } - ]; - } - ]; - }; - - postgresql = { - ensureDatabases = [db]; - ensureUsers = [ - { - name = db; - ensureDBOwnership = true; - } - ]; - }; - }; - }; -} |