From 5b0cab98d5341e9b3308f5ec5af490de9c7939cd Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 14 Nov 2025 07:42:28 +0100 Subject: [PATCH] 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. --- .../nixos/services/systemd-email-notify/default.nix | 11 ++++++++--- systems/x86_64-linux/mx/default.nix | 1 + systems/x86_64-linux/sgx/default.nix | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/nixos/services/systemd-email-notify/default.nix b/modules/nixos/services/systemd-email-notify/default.nix index 2a812ee..fb55801 100644 --- a/modules/nixos/services/systemd-email-notify/default.nix +++ b/modules/nixos/services/systemd-email-notify/default.nix @@ -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 [ ]; diff --git a/systems/x86_64-linux/mx/default.nix b/systems/x86_64-linux/mx/default.nix index 21a6d0e..b3a428b 100644 --- a/systems/x86_64-linux/mx/default.nix +++ b/systems/x86_64-linux/mx/default.nix @@ -19,6 +19,7 @@ ]; metacfg = { + emailOnFailure.enable = true; base.enable = true; nix.enable = true; podman.enable = true; diff --git a/systems/x86_64-linux/sgx/default.nix b/systems/x86_64-linux/sgx/default.nix index 61638af..b1f94ee 100644 --- a/systems/x86_64-linux/sgx/default.nix +++ b/systems/x86_64-linux/sgx/default.nix @@ -21,6 +21,7 @@ ]; metacfg = { + emailOnFailure.enable = true; base.enable = true; gui.enable = true; nix-ld.enable = true;