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/network/default.nix | 1 + modules/notifications/default.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 modules/notifications/default.nix (limited to 'modules') diff --git a/modules/network/default.nix b/modules/network/default.nix index 53e64b0..55a4c43 100644 --- a/modules/network/default.nix +++ b/modules/network/default.nix @@ -21,6 +21,7 @@ in "syncthing.local" = { inherit host; port = ports.syncthing; }; "lidarr.local" = { inherit host; port = ports.lidarr; }; "git.local" = { inherit host; port = 80; basePath = "/gitweb/"; }; + "ntfy.local" = { inherit host; port = ports.ntfy; }; }; }; 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