74 lines
2.0 KiB
Nix
74 lines
2.0 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
cfg = config.email;
|
|
in
|
|
|
|
### --> Mail notifications configuration
|
|
{
|
|
options.email = {
|
|
enable = lib.mkEnableOption "Email sending functionality";
|
|
fromAddress = lib.mkOption {
|
|
description = "The 'from' address";
|
|
type = lib.types.str;
|
|
default = "no-reply@DOMAIN_NAME";
|
|
};
|
|
userAddress = lib.mkOption {
|
|
description = "The 'to' address";
|
|
type = lib.types.str;
|
|
default = "EMAIL_ADDRESS";
|
|
};
|
|
adminAddress = lib.mkOption {
|
|
description = "The admin email address to receive alerts in copy";
|
|
type = lib.types.str;
|
|
default = "admin@numbus.eu";
|
|
};
|
|
smtpServer = lib.mkOption {
|
|
description = "The SMTP server address";
|
|
type = lib.types.str;
|
|
default = "SENDER_MAIL_DOMAIN";
|
|
};
|
|
smtpPort = lib.mkOption {
|
|
description = "The SMTP port";
|
|
type = lib.types.port;
|
|
default = 465;
|
|
};
|
|
smtpUsername = lib.mkOption {
|
|
description = "The SMTP username";
|
|
type = lib.types.str;
|
|
default = "SENDER_MAIL_ADDRESS";
|
|
};
|
|
smtpPasswordPath = lib.mkOption {
|
|
description = "Path to the secret containing SMTP password";
|
|
type = lib.types.path;
|
|
default = config.sops.secrets.sender_email_address_password.path;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.etc."aliases".text = ''
|
|
root: ${config.email.userAddress}, ${config.email.adminAddress}
|
|
default: ${config.email.userAddress}, ${config.email.adminAddress}
|
|
'';
|
|
|
|
programs.msmtp = {
|
|
enable = true;
|
|
defaults = {
|
|
aliases = "/etc/aliases";
|
|
timeout = 60;
|
|
syslog = "on";
|
|
};
|
|
accounts.default = {
|
|
auth = true;
|
|
host = config.email.smtpServer;
|
|
port = config.email.smtpPort;
|
|
from = config.email.fromAddress;
|
|
user = config.email.smtpUsername;
|
|
tls = true;
|
|
tls_starttls = false;
|
|
passwordeval = "${pkgs.coreutils}/bin/cat ${config.email.smtpPasswordPath}";
|
|
};
|
|
};
|
|
};
|
|
### Mail notifications configuration <--
|
|
} |