nix-home/modules/cloud/conduit/default.nix
2022-06-11 12:09:01 -04:00

64 lines
1.3 KiB
Nix

{ 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;
};
well-known_port = mkOption {
type = types.int;
default = 6166;
};
};
config.services.matrix-conduit = mkIf cfg.enable {
enable = true;
settings.global = {
inherit (cfg) port allow_registration;
server_name = cfg.host;
database_backend = "rocksdb";
};
};
# 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`)";
};
};
}