{ pkgs, lib, config, ... }: { options.services.email-notify.enable = lib.mkEnableOption "Enable a service which can be used to send emails"; config = lib.mkIf config.services.email-notify.enable { age.secrets.password-leah-at-f2k1-de.file = ../../secrets/passwords/leah-at-f2k1-de.age; programs.msmtp = { enable = true; setSendmail = false; accounts = { default = { auth = true; tls = true; host = "rx300.kunbox.net"; port = 587; user = "leah@f2k1.de"; from = "${config.networking.fqdn} "; passwordeval = "cat ${config.age.secrets.password-leah-at-f2k1-de.path}"; }; }; }; systemd.services."email-notify@" = { serviceConfig = { ExecStart = '' ${pkgs.runtimeShell} -c "{ echo -n 'Subject:[${config.networking.fqdn}] Service failed: %i\n\n' & ${pkgs.systemd}/bin/systemctl status %i;} | ${pkgs.msmtp}/bin/msmtp -v notify@ctu.cx" ''; }; }; }; }