From 7d377018116f72037a8aea873e199f20b6c04aaf Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 25 Sep 2021 13:20:22 +0200 Subject: [PATCH] modules: services: matrix: use 'mailConfigFile' In preparation of the migration to agenix. --- machines/porthos/services.nix | 14 +++++++-- modules/services/matrix.nix | 54 ++++++++--------------------------- 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/machines/porthos/services.nix b/machines/porthos/services.nix index 84f4d2f..9c74276 100644 --- a/machines/porthos/services.nix +++ b/machines/porthos/services.nix @@ -65,8 +65,18 @@ in # Matrix backend and Element chat front-end matrix = { enable = true; - mail = my.secrets.matrix.mail; - secret = my.secrets.matrix.secret; + mailConfigFile = builtins.toFile "matrix-mail.yaml" '' + email: + smtp_host: "smtp.migadu.com" + smtp_port: 587 + smtp_user: "${my.secrets.matrix.mail.username}" + smtp_pass: "${my.secrets.matrix.mail.password}" + notif_from: "${my.secrets.matrix.mail.notifFrom}" + # Refuse to connect unless the server supports STARTTLS. + require_transport_security: true + ''; + # Only necessary when doing the initial registration + # secret = "change-me"; }; miniflux = { enable = true; diff --git a/modules/services/matrix.nix b/modules/services/matrix.nix index 4d6394e..af26a83 100644 --- a/modules/services/matrix.nix +++ b/modules/services/matrix.nix @@ -20,43 +20,18 @@ in enable = mkEnableOption "Matrix Synapse"; secret = mkOption { - type = types.str; + type = with types; nullOr str; + default = null; example = "deadbeef"; description = "Shared secret to register users"; }; - mail = { - host = mkOption { - type = types.str; - default = "smtp.migadu.com"; - example = "smtp.example.com"; - description = "Which host should be used for SMTP"; - }; - - port = mkOption { - type = types.port; - default = 587; - example = 25; - description = "Which port should be used for SMTP"; - }; - - username = mkOption { - type = types.str; - example = "matrix@example.com"; - description = "Which username should be used to connect"; - }; - - password = mkOption { - type = types.str; - example = "password"; - description = "Which password should be used to connect"; - }; - - notifFrom = mkOption { - type = types.str; - example = ""; - description = "Which address should be used for `From` field"; - }; + mailConfigFile = mkOption { + type = types.str; + example = "/var/lib/matrix/email-config.yaml"; + description = '' + Configuration file for mail setup. + ''; }; }; @@ -106,16 +81,11 @@ in extraConfig = '' experimental_features: spaces_enabled: true - - email: - smtp_host: "${cfg.mail.host}" - smtp_port: ${toString cfg.mail.port} - smtp_user: "${cfg.mail.username}" - smtp_pass: "${cfg.mail.password}" - notif_from: "${cfg.mail.notifFrom}" - # Refuse to connect unless the server supports STARTTLS. - require_transport_security: true ''; + + extraConfigFiles = [ + cfg.mailConfigFile + ]; }; my.services.nginx.virtualHosts = [