From 1b6258e363af89272080e9cc9edc03b08ecd92fc Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 9 Jun 2021 14:53:11 +0200 Subject: [PATCH] services: matrix: add smtp server --- .gitattributes | 1 + hosts/poseidon/default.nix | 1 + secrets/default.nix | 2 ++ secrets/matrix-email-config.nix | Bin 0 -> 402 bytes services/matrix.nix | 59 ++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 secrets/matrix-email-config.nix diff --git a/.gitattributes b/.gitattributes index 5a52419..fdfc04b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ secrets/**/*.secret filter=git-crypt diff=git-crypt +secrets/matrix-email-config.nix filter=git-crypt diff=git-crypt secrets/wireguard.nix filter=git-crypt diff=git-crypt home/secrets/*.secret filter=git-crypt diff=git-crypt diff --git a/hosts/poseidon/default.nix b/hosts/poseidon/default.nix index c0c6e31..61463f7 100644 --- a/hosts/poseidon/default.nix +++ b/hosts/poseidon/default.nix @@ -94,6 +94,7 @@ in matrix = { enable = true; registration_shared_secret = secrets.matrix-registration-shared-secret; + emailConfig = secrets.matrixEmailConfig; }; monitoring = { diff --git a/secrets/default.nix b/secrets/default.nix index a76b282..6a0a042 100644 --- a/secrets/default.nix +++ b/secrets/default.nix @@ -18,5 +18,7 @@ with lib; borg-backup = import ./borg-backup { inherit lib; }; wireguard = pkgs.callPackage ./wireguard.nix { }; + + matrixEmailConfig = import ./matrix-email-config.nix; }; } diff --git a/secrets/matrix-email-config.nix b/secrets/matrix-email-config.nix new file mode 100644 index 0000000000000000000000000000000000000000..ef7eed831c4232b875be77e00bf40096c41808e9 GIT binary patch literal 402 zcmV;D0d4*OM@dveQdv+`0E-F|k#-K9`wE!71CtsJ2lGY4)WD-q-MO}Pha$a$NyL2r zFnxe+m+v3ogj2zL>ouPhG>CqdIFTS#bHkl{D};+Pna0S~?YvD}Mq0n;Ve<-w%ikvE zu$Iplk{n0RhP8K(jmXwnRW%oG|J4Nhw;{on3AklAH6nZdF6-;SR!)dx0BkSJ?84(kDQX*xe=;+Uf*8Pw-bg%(u;!JokrUP$a>S=u->N7 zMBYa?@$nHWhhGrx5=nF0#_AeYsXfp~TBXsx*gpK+t_;^6Go;g)#B#sB~S literal 0 HcmV?d00001 diff --git a/services/matrix.nix b/services/matrix.nix index aaa696f..228cabf 100644 --- a/services/matrix.nix +++ b/services/matrix.nix @@ -28,6 +28,31 @@ in { example = "deadbeef"; description = "Shared secret to register users"; }; + + emailConfig = mkOption { + type = types.submodule { + options = { + smtpHost = mkOption { + type = types.str; + default = "localhost"; + }; + smtpPort = mkOption { + type = types.port; + default = 587; + }; + smtpUser = mkOption { + type = types.str; + }; + smtpPass = mkOption { + type = types.str; + }; + notifFrom = mkOption { + type = types.str; + example = "Your Friendly %(app)s homeserver "; + }; + }; + }; + }; }; config = lib.mkIf cfg.enable { @@ -69,6 +94,40 @@ in { extraConfig = '' experimental_features: { spaces_enabled: true } use_presence: false + + email: + # The hostname of the outgoing SMTP server to use. Defaults to 'localhost'. + # + smtp_host: "${cfg.emailConfig.smtpHost}" + + # The port on the mail server for outgoing SMTP. Defaults to 25. + # + smtp_port: ${toString cfg.emailConfig.smtpPort} + + # Username/password for authentication to the SMTP server. By default, no + # authentication is attempted. + # + smtp_user: "${cfg.emailConfig.smtpUser}" + smtp_pass: "${cfg.emailConfig.smtpPass}" + + # Uncomment the following to require TLS transport security for SMTP. + # By default, Synapse will connect over plain text, and will then switch to + # TLS via STARTTLS *if the SMTP server supports it*. If this option is set, + # Synapse will refuse to connect unless the server supports STARTTLS. + # + require_transport_security: true + + # notif_from defines the "From" address to use when sending emails. + # It must be set if email sending is enabled. + # + # The placeholder '%(app)s' will be replaced by the application name, + # which is normally 'app_name' (below), but may be overridden by the + # Matrix client application. + # + # Note that the placeholder must be written '%(app)s', including the + # trailing 's'. + # + notif_from: "${cfg.emailConfig.notifFrom}" ''; logConfig = ''