Add ignoredUnits option; skip logrotate failures on s0 because they are spurious
This commit is contained in:
@@ -19,6 +19,12 @@
|
|||||||
default = "";
|
default = "";
|
||||||
description = "Extra arguments to pass to curl (e.g. --proxy http://host:port).";
|
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" {
|
config = lib.mkIf config.thisMachine.hasRole."ntfy" {
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ in
|
|||||||
EnvironmentFile = "/run/agenix/ntfy-token";
|
EnvironmentFile = "/run/agenix/ntfy-token";
|
||||||
ExecStart = "${pkgs.writeShellScript "ntfy-failure-notify" ''
|
ExecStart = "${pkgs.writeShellScript "ntfy-failure-notify" ''
|
||||||
unit="$1"
|
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)
|
logfile=$(mktemp)
|
||||||
trap 'rm -f "$logfile"' EXIT
|
trap 'rm -f "$logfile"' EXIT
|
||||||
${pkgs.systemd}/bin/journalctl -u "$unit" -n 50 --no-pager -o short > "$logfile" 2>/dev/null \
|
${pkgs.systemd}/bin/journalctl -u "$unit" -n 50 --no-pager -o short > "$logfile" 2>/dev/null \
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
networking.hostName = "s0";
|
networking.hostName = "s0";
|
||||||
|
|
||||||
|
ntfy-alerts.ignoredUnits = [ "logrotate" ];
|
||||||
|
|
||||||
# system.autoUpgrade.enable = true;
|
# system.autoUpgrade.enable = true;
|
||||||
|
|
||||||
nix.gc.automatic = lib.mkForce false; # allow the nix store to serve as a build cache
|
nix.gc.automatic = lib.mkForce false; # allow the nix store to serve as a build cache
|
||||||
|
|||||||
Reference in New Issue
Block a user