2024-03-29 23:15:10 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
|
|
|
|
options.dgn-notify = {
|
|
|
|
enable = lib.mkEnableOption "DGNum email notification cli" // {
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkIf config.dgn-notify.enable {
|
2024-04-20 20:40:26 +02:00
|
|
|
services.mail.sendmailSetuidWrapper.group = lib.mkForce "mail";
|
|
|
|
users.groups.mail = { };
|
|
|
|
|
2024-03-29 23:15:10 +01:00
|
|
|
programs.msmtp = {
|
|
|
|
enable = true;
|
2024-04-20 20:40:26 +02:00
|
|
|
setSendmail = true;
|
2024-03-29 23:15:10 +01:00
|
|
|
accounts.default = {
|
|
|
|
tls = true;
|
|
|
|
tls_starttls = false;
|
|
|
|
port = 465;
|
|
|
|
auth = true;
|
|
|
|
host = "kurisu.lahfa.xyz";
|
|
|
|
from = "noreply@infra.dgnum.eu";
|
|
|
|
user = "web-services@infra.dgnum.eu";
|
|
|
|
passwordeval = "cat ${config.age.secrets.mail.path}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.systemd-notify = {
|
|
|
|
enable = true;
|
|
|
|
command = builtins.toString (
|
|
|
|
pkgs.writeShellScript "sendmail" ''
|
|
|
|
${pkgs.msmtp}/bin/sendmail -i -t <<ERRMAIL
|
|
|
|
To: admins+monitoring@dgnum.eu
|
|
|
|
Subject: [$HOSTNAME] Systemd failure: $1
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
|
|
|
|
$(systemctl status --full "$1")
|
|
|
|
ERRMAIL
|
|
|
|
''
|
|
|
|
);
|
|
|
|
};
|
|
|
|
age-secrets.sources = [ ./. ];
|
|
|
|
};
|
|
|
|
}
|