nix-home/modules/cloud/conduit/default.nix

64 lines
1.3 KiB
Nix
Raw Normal View History

2022-06-10 20:50:07 +00:00
{ pkgs, config, lib, ... }:
let
cfg = config.cloud.conduit;
in
with lib;
{
options.cloud.conduit = {
enable = mkEnableOption "Enable the conduit server";
host = mkOption {
type = types.str;
default = "m.nkagami.me";
};
port = mkOption {
type = types.int;
default = 6167;
};
allow_registration = mkOption {
type = types.bool;
default = false;
};
2022-06-10 21:37:19 +00:00
well-known_port = mkOption {
type = types.int;
default = 6166;
};
2022-06-10 20:50:07 +00:00
};
config.services.matrix-conduit = mkIf cfg.enable {
enable = true;
settings.global = {
inherit (cfg) port allow_registration;
server_name = cfg.host;
database_backend = "rocksdb";
};
};
2022-06-10 21:37:19 +00:00
# Serving .well-known files
config.services.nginx = mkIf cfg.enable {
enable = true;
virtualHosts.conduit-well-kwown = {
listen = [{ addr = "127.0.0.1"; port = cfg.well-known_port; }];
root = pkgs.writeTextDir ".well-known/matrix/server" ''
{
"m.server": "${cfg.host}:443"
}
'';
};
};
config.cloud.traefik.hosts = mkIf cfg.enable {
conduit = { inherit (cfg) port host; };
conduit-well-kwown = {
port = cfg.well-known_port;
filter = "Host(`${cfg.host}`) && PathPrefix(`/.well-known`)";
};
2022-06-10 20:50:07 +00:00
};
}