diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-06-13 19:18:13 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-06-13 19:18:13 +0530 |
| commit | 642dcf862cb0637bcb80a38702b8ed5ec1264082 (patch) | |
| tree | dd5af131dc25da7fb75124bc1de7cd116d1345c0 /modules | |
| parent | 60e26854dac063f0732f44babb3c7d3dbf7888a0 (diff) | |
| download | homeserver-nixos-config-642dcf862cb0637bcb80a38702b8ed5ec1264082.tar.gz homeserver-nixos-config-642dcf862cb0637bcb80a38702b8ed5ec1264082.zip | |
Add ntfy for notifications
Diffstat (limited to '')
| -rw-r--r-- | modules/network/default.nix | 1 | ||||
| -rw-r--r-- | modules/notifications/default.nix | 27 |
2 files changed, 28 insertions, 0 deletions
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" + '') + ]; +} |
