diff options
Diffstat (limited to 'modules/matrix/dendrite.nix')
-rw-r--r-- | modules/matrix/dendrite.nix | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/modules/matrix/dendrite.nix b/modules/matrix/dendrite.nix index c391ba0..960096c 100644 --- a/modules/matrix/dendrite.nix +++ b/modules/matrix/dendrite.nix @@ -6,22 +6,21 @@ this, ... }: -with lib; let cfg = config.nixfiles.modules.matrix.dendrite; in { options.nixfiles.modules.matrix.dendrite = { - enable = mkEnableOption "Dendrite Matrix server"; + enable = lib.mkEnableOption "Dendrite Matrix server"; - port = mkOption { + port = lib.mkOption { description = "Port."; - type = with types; port; + type = lib.types.port; default = 8008; }; - domain = mkOption { - type = types.str; + domain = lib.mkOption { + type = lib.types.str; default = config.networking.domain; description = "Domain name sans protocol scheme."; }; @@ -31,7 +30,7 @@ in let db = "dendrite"; in - mkIf cfg.enable { + lib.mkIf cfg.enable { ark.directories = [ "/var/lib/dendrite" "/var/lib/private/dendrite" @@ -58,14 +57,16 @@ in add_header Content-Type application/json; add_header Access-Control-Allow-Origin *; ''; - return = "200 '${generators.toJSON { } { "m.server" = "${cfg.domain}:443"; }}'"; + return = "200 '${lib.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}"; }}'"; + return = "200 '${ + lib.generators.toJSON { } { "m.homeserver".base_url = "https://${cfg.domain}"; } + }'"; }; }; }; @@ -119,7 +120,7 @@ in serviceConfig = let needsPrivileges = cfg.port < 1024; - capabilities = [ "" ] ++ optionals needsPrivileges [ "CAP_NET_BIND_SERVICE" ]; + capabilities = [ "" ] ++ lib.optionals needsPrivileges [ "CAP_NET_BIND_SERVICE" ]; in { Restart = "on-failure"; @@ -185,13 +186,13 @@ in ]; }; in - concatStringsSep " " [ - (getExe pkgs.envsubst) + lib.concatStringsSep " " [ + (lib.getExe pkgs.envsubst) "-i ${(pkgs.formats.yaml { }).generate "dendrite.yaml" settings}" "-o /run/dendrite/dendrite.yaml" ]; - ExecStart = concatStringsSep " " [ - (getExe' pkgs.dendrite "dendrite") + ExecStart = lib.concatStringsSep " " [ + (lib.getExe' pkgs.dendrite "dendrite") "--config /run/dendrite/dendrite.yaml" "--http-bind-address 127.0.0.1:${toString cfg.port}" ]; @@ -237,13 +238,11 @@ in }; }; - topology = with cfg; { - nodes.${this.hostname}.services.dendrite = { - name = "Dendrite"; - icon = "${inputs.homelab-svg-assets}/assets/matrix-white.svg"; - info = domain; - details.listen.text = "127.0.0.1:${toString port}"; - }; + topology.nodes.${this.hostname}.services.dendrite = { + name = "Dendrite"; + icon = "${inputs.homelab-svg-assets}/assets/matrix-white.svg"; + info = cfg.domain; + details.listen.text = "127.0.0.1:${toString cfg.port}"; }; }; } |