From ec25e095a26ad1e4823887a6653132948ebc5f87 Mon Sep 17 00:00:00 2001 From: azahi Date: Wed, 5 Feb 2025 17:18:02 +0300 Subject: 2025-02-05 --- modules/matrix/dendrite.nix | 29 +++++++++++++++-------------- modules/matrix/element.nix | 15 +++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'modules/matrix') diff --git a/modules/matrix/dendrite.nix b/modules/matrix/dendrite.nix index c391ba0..89704ea 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}" ]; diff --git a/modules/matrix/element.nix b/modules/matrix/element.nix index 01b991e..c1c29a7 100644 --- a/modules/matrix/element.nix +++ b/modules/matrix/element.nix @@ -4,28 +4,27 @@ pkgs, ... }: -with lib; let cfg = config.nixfiles.modules.matrix.element; in { options.nixfiles.modules.matrix.element = { - enable = mkEnableOption "Element, a Matrix web interface"; + enable = lib.mkEnableOption "Element, a Matrix web interface"; - domain = mkOption { + domain = lib.mkOption { description = "Domain name sans protocol scheme."; - type = with types; nullOr str; + type = with lib.types; nullOr str; default = "element.${config.networking.domain}"; }; - homeserver = mkOption { + homeserver = lib.mkOption { description = "Default Matrix homeserver."; - type = with types; str; - default = my.domain.azahi; + type = lib.types.str; + default = lib.my.domain.azahi; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { assertion = -- cgit 1.4.1