diff --git a/flake.nix b/flake.nix index fd0f5a7..9ee0a83 100644 --- a/flake.nix +++ b/flake.nix @@ -246,6 +246,7 @@ metrics = "metrics.${baseName}"; minecraft = "minecraft.${baseName}"; n8n = "n8n.${baseName}"; + notifications = "ntfy.${baseName}"; prometheus = "prom.${baseName}"; paperless = "paper.${baseName}"; secrets = "vault.${baseName}"; diff --git a/hosts/flame/default.nix b/hosts/flame/default.nix index c16ca90..abf4537 100644 --- a/hosts/flame/default.nix +++ b/hosts/flame/default.nix @@ -81,6 +81,7 @@ inputs.nixpkgs.lib.nixosSystem rec { services.vaultwarden.enable = true; services.minecraft-server.enable = true; # Setup Minecraft server services.n8n.enable = true; + services.ntfy-sh.enable = true; system.autoUpgrade.enable = true; # Allows private remote access over the internet diff --git a/modules/common/default.nix b/modules/common/default.nix index 7084193..1ba293a 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -129,6 +129,10 @@ type = lib.types.str; description = "Hostname for n8n automation."; }; + notifications = lib.mkOption { + type = lib.types.str; + description = "Hostname for push notification services (ntfy)."; + }; transmission = lib.mkOption { type = lib.types.str; description = "Hostname for peer2peer downloads (Transmission)."; diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index d2bb72a..b59a537 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -26,6 +26,7 @@ ./n8n.nix ./netdata.nix ./nextcloud.nix + ./ntfy.nix ./paperless.nix ./postgresql.nix ./prometheus.nix diff --git a/modules/nixos/services/ntfy.nix b/modules/nixos/services/ntfy.nix new file mode 100644 index 0000000..8d2ddc9 --- /dev/null +++ b/modules/nixos/services/ntfy.nix @@ -0,0 +1,33 @@ +{ config, lib, ... }: + +{ + + config = lib.mkIf config.services.ntfy-sh.enable { + services.ntfy-sh = { + settings = rec { + base-url = "https://${config.hostnames.notifications}"; + upstream-base-url = "https://ntfy.sh"; + listen-http = ":8333"; + behind-proxy = true; + auth-default-access = "deny-all"; + auth-file = "/var/lib/ntfy-sh/user.db"; + }; + }; + + caddy.routes = [ + { + match = [ { host = [ config.hostnames.notifications ]; } ]; + handle = [ + { + handler = "reverse_proxy"; + upstreams = [ { dial = "localhost${config.services.ntfy-sh.settings.listen-http}"; } ]; + } + ]; + } + ]; + + # Configure Cloudflare DNS to point to this machine + services.cloudflare-dyndns.domains = [ config.hostnames.notifications ]; + + }; +}