modules: services: matrix: use 'mailConfigFile'

In preparation of the migration to agenix.
This commit is contained in:
Bruno BELANYI 2021-09-25 13:20:22 +02:00
parent 0f2c20e51d
commit ba10af0644
2 changed files with 24 additions and 44 deletions

View file

@ -65,8 +65,18 @@ in
# Matrix backend and Element chat front-end # Matrix backend and Element chat front-end
matrix = { matrix = {
enable = true; enable = true;
mail = my.secrets.matrix.mail; mailConfigFile = builtins.toFile "matrix-mail.yaml" ''
secret = my.secrets.matrix.secret; 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 = { miniflux = {
enable = true; enable = true;

View file

@ -20,43 +20,18 @@ in
enable = mkEnableOption "Matrix Synapse"; enable = mkEnableOption "Matrix Synapse";
secret = mkOption { secret = mkOption {
type = types.str; type = with types; nullOr str;
default = null;
example = "deadbeef"; example = "deadbeef";
description = "Shared secret to register users"; description = "Shared secret to register users";
}; };
mail = { mailConfigFile = mkOption {
host = mkOption { type = types.str;
type = types.str; example = "/var/lib/matrix/email-config.yaml";
default = "smtp.migadu.com"; description = ''
example = "smtp.example.com"; Configuration file for mail setup.
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 = "<matrix@example.com>";
description = "Which address should be used for `From` field";
};
}; };
}; };
@ -106,16 +81,11 @@ in
extraConfig = '' extraConfig = ''
experimental_features: experimental_features:
spaces_enabled: true 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 = [ my.services.nginx.virtualHosts = [