From a63f682aeb27451f2ca3c969978111417d26a7ad Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 13 May 2024 23:31:34 +0200 Subject: [PATCH] feat(monitoring): Add admin emails --- modules/dgn-notify/default.nix | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/modules/dgn-notify/default.nix b/modules/dgn-notify/default.nix index 4a9daa5..174aa2f 100644 --- a/modules/dgn-notify/default.nix +++ b/modules/dgn-notify/default.nix @@ -2,17 +2,36 @@ config, pkgs, lib, + meta, + nodeMeta, ... }: + +let + inherit (lib) + concatStringsSep + mkEnableOption + mkForce + mkIf + ; + + emails = concatStringsSep ", " ( + builtins.map (name: meta.organization.members.${name}.email) nodeMeta.admins + ); + + cfg = config.dgn-notify; +in + { options.dgn-notify = { - enable = lib.mkEnableOption "DGNum email notification cli" // { + enable = mkEnableOption "DGNum email notification cli" // { default = true; }; }; - config = lib.mkIf config.dgn-notify.enable { - services.mail.sendmailSetuidWrapper.group = lib.mkForce "mail"; + + config = mkIf cfg.enable { + services.mail.sendmailSetuidWrapper.group = mkForce "mail"; users.groups.mail = { }; programs.msmtp = { @@ -29,12 +48,13 @@ passwordeval = "cat ${config.age.secrets.mail.path}"; }; }; + services.systemd-notify = { enable = true; command = builtins.toString ( pkgs.writeShellScript "sendmail" '' ${pkgs.msmtp}/bin/sendmail -i -t <