diff options
Diffstat (limited to '')
| -rw-r--r-- | modules/notifications/default.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/notifications/default.nix b/modules/notifications/default.nix new file mode 100644 index 0000000..87df67d --- /dev/null +++ b/modules/notifications/default.nix @@ -0,0 +1,27 @@ +{ lib, pkgs, ... }: +let + settings = import ../../settings.nix { inherit lib; }; + host = settings.network.host; + ports = settings.network.ports; + url = "http://${host}:${toString ports.ntfy}"; +in +{ + networking.firewall.allowedTCPPorts = [ ports.ntfy ]; + + services.ntfy-sh = { + enable = true; + settings = { + listen-http = ":${toString ports.ntfy}"; + base-url = url; + }; + }; + + environment.systemPackages = [ + (pkgs.writeShellScriptBin "push-ntfy" '' + set -eu; + topic="$1"; shift 1; + body="$1"; shift 1; + ${pkgs.ntfy-sh}/bin/ntfy pub "$@" "${url}/$topic" "$body" + '') + ]; +} |
