hosts/options/email.nix

50 lines
1.4 KiB
Nix
Raw Normal View History

2023-02-26 16:42:49 +01:00
{ config, lib, ... }:
with lib;
let
cfg = config.email;
in
2023-02-26 16:42:49 +01:00
{
options.email = {
enable = lib.mkEnableOption "Allow sending system status e-mails via sendmail";
2023-02-26 16:42:49 +01:00
fromAddress = mkOption {
type = types.str;
example = "noreply@example.com";
description = ''
E-Mail address automated e-mails are sent from.
'';
};
fromIdentity = mkOption {
type = types.str;
default = "${config.networking.hostName} <${config.email.fromAddress}>";
example = "Maintenance (no reply) <noreply@example.com>";
description = ''
E-Mail identity automated e-mails are sent from.
'';
};
adminEmail = mkOption {
type = types.str;
example = "admin@example.com";
description = ''
E-Mail address automated e-mails are sent to.
'';
};
};
config.programs.msmtp = lib.mkIf cfg.enable {
enable = true;
setSendmail = true;
accounts = {
default = {
auth = true;
host = "gvfr.de";
passwordeval = "cat /secrets/email_password.txt";
user = cfg.fromAddress;
from = cfg.fromAddress;
port = 465;
tls = true;
tls_starttls = false;
};
};
};
2023-02-26 16:42:49 +01:00
}