Add ignoredUnits option; skip logrotate failures on s0 because they are spurious

This commit is contained in:
2026-03-03 21:46:19 -08:00
parent 6bd1b4466e
commit c6eeea982e
3 changed files with 14 additions and 0 deletions

View File

@@ -19,6 +19,12 @@
default = "";
description = "Extra arguments to pass to curl (e.g. --proxy http://host:port).";
};
ignoredUnits = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Unit names to skip failure notifications for.";
};
};
config = lib.mkIf config.thisMachine.hasRole."ntfy" {

View File

@@ -14,6 +14,12 @@ in
EnvironmentFile = "/run/agenix/ntfy-token";
ExecStart = "${pkgs.writeShellScript "ntfy-failure-notify" ''
unit="$1"
ignored_units=(${lib.concatMapStringsSep " " (u: lib.escapeShellArg u) cfg.ignoredUnits})
for ignored in "''${ignored_units[@]}"; do
if [[ "$unit" == "$ignored" ]]; then
exit 0
fi
done
logfile=$(mktemp)
trap 'rm -f "$logfile"' EXIT
${pkgs.systemd}/bin/journalctl -u "$unit" -n 50 --no-pager -o short > "$logfile" 2>/dev/null \

View File

@@ -9,6 +9,8 @@
networking.hostName = "s0";
ntfy-alerts.ignoredUnits = [ "logrotate" ];
# system.autoUpgrade.enable = true;
nix.gc.automatic = lib.mkForce false; # allow the nix store to serve as a build cache