2022-05-02 05:47:52 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
2022-06-15 15:47:36 +02:00
|
|
|
let
|
|
|
|
sender = "akasroua@disroot.org";
|
|
|
|
recipient = "akasroua+smart@disroot.org";
|
|
|
|
|
|
|
|
in {
|
2022-05-02 05:47:52 +02:00
|
|
|
# Notify when a disk starts going haywire
|
|
|
|
services.smartd = {
|
|
|
|
enable = true;
|
|
|
|
notifications.mail = {
|
|
|
|
enable = true;
|
2022-06-15 15:47:36 +02:00
|
|
|
sender = sender;
|
|
|
|
recipient = recipient;
|
2022-05-02 05:47:52 +02:00
|
|
|
mailer = "${msmtp}/bin/msmtp -t --read-envelope-from";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-06-15 15:47:36 +02:00
|
|
|
# Notify about zpool problems
|
|
|
|
services.zfs.zed = {
|
|
|
|
enableMail = false;
|
|
|
|
settings = {
|
|
|
|
ZED_EMAIL_ADDR = [ "root" ];
|
|
|
|
ZED_EMAIL_PROG = "${msmtp}/bin/msmtp";
|
|
|
|
ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# HACK Use an alias to use msmtp instead of the ZED mailer
|
|
|
|
environment.etc.aliases.text = ''
|
|
|
|
root: ${recipient}
|
|
|
|
'';
|
|
|
|
|
2022-05-02 05:47:52 +02:00
|
|
|
# Set up msmtp as notifier
|
|
|
|
programs.msmtp = {
|
|
|
|
enable = true;
|
|
|
|
defaults = {
|
2022-06-15 15:47:36 +02:00
|
|
|
auth = true;
|
|
|
|
aliases = "/etc/aliases";
|
2022-05-02 05:47:52 +02:00
|
|
|
port = 587;
|
|
|
|
tls = true;
|
|
|
|
};
|
|
|
|
accounts = {
|
|
|
|
default = {
|
|
|
|
host = "disroot.org";
|
|
|
|
user = "akasroua@disroot.org";
|
|
|
|
passwordeval = "${coreutils}/bin/cat ${config.age.secrets.msmtp.path}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|