From 642dcf862cb0637bcb80a38702b8ed5ec1264082 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 13 Jun 2025 19:18:13 +0530 Subject: Add ntfy for notifications --- modules/notifications/default.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 modules/notifications/default.nix (limited to 'modules/notifications') 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" + '') + ]; +} -- cgit v1.3.1