feat(systems): enable email notifications on failure

- Added `emailOnFailure.enable` option to metacfg with a default of `false`.
- Enabled email notifications on failure for SGX and MX systems.
- Enhanced `systemd-email-notify` module to support the new configuration.
This commit is contained in:
Harald Hoyer 2025-11-14 07:42:28 +01:00
parent 57c8f86fde
commit 5b0cab98d5
3 changed files with 10 additions and 3 deletions

View file

@ -4,10 +4,11 @@
pkgs,
...
}:
with lib;
with lib.metacfg;
let
cfg = config.metacfg.emailOnFailure;
checkConditions = pkgs.writeScript "checkConditions" ''
#!/bin/sh
STATUS=$(systemctl status --full "$1")
@ -34,6 +35,10 @@ let
in
{
options = {
metacfg.emailOnFailure = with types; {
enable = mkBoolOpt false "Whether or not to send mails on failure.";
};
systemd.email-notify.mailTo = mkOption {
type = types.str;
default = "admin";
@ -55,7 +60,7 @@ in
};
};
config = {
config = mkIf cfg.enable {
systemd.services."email@" = {
description = "Sends a status mail via sendmail on service failures.";
onFailure = mkForce [ ];

View file

@ -19,6 +19,7 @@
];
metacfg = {
emailOnFailure.enable = true;
base.enable = true;
nix.enable = true;
podman.enable = true;

View file

@ -21,6 +21,7 @@
];
metacfg = {
emailOnFailure.enable = true;
base.enable = true;
gui.enable = true;
nix-ld.enable = true;