summaryrefslogtreecommitdiff
path: root/nix/modules/ntfy-sh.nix
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@nullring.xyz>2026-03-01 23:51:02 -0800
committerPreston Pan <ret2pop@nullring.xyz>2026-03-01 23:51:02 -0800
commita05e0614c1bb75f77717a943dc4ac75a0cca4652 (patch)
treed52ddee9db6d6eabbafc73f04aa83f6bbcd7f0c5 /nix/modules/ntfy-sh.nix
parent75439737613d86975856c4bff0a1257f58fd1b1f (diff)
add everything; add CI
Diffstat (limited to 'nix/modules/ntfy-sh.nix')
-rw-r--r--nix/modules/ntfy-sh.nix41
1 files changed, 36 insertions, 5 deletions
diff --git a/nix/modules/ntfy-sh.nix b/nix/modules/ntfy-sh.nix
index 0eeac78..3cbab0e 100644
--- a/nix/modules/ntfy-sh.nix
+++ b/nix/modules/ntfy-sh.nix
@@ -1,19 +1,32 @@
{ pkgs, lib, config, ... }:
+let
+ serverName = "ntfy.${config.monorepo.vars.remoteHost}";
+ port = 2586;
+ ntfySecret = "ntfy";
+in
{
+ sops.secrets."${ntfySecret}" = lib.mkIf config.services.ntfy-sh.enable {
+ format = "yaml";
+ owner = "ntfy-sh";
+ };
+
services.ntfy-sh = {
enable = lib.mkDefault config.monorepo.profiles.server.enable;
settings = {
- base-url = "https://ntfy.${config.monorepo.vars.remoteHost}";
- listen-http = "127.0.0.1:2586";
- envrionmentFile = "/run/secrets/ntfy";
+ base-url = "https://${serverName}";
+ listen-http = "127.0.0.1:${toString port}";
+ envrionmentFile = "/run/secrets/${ntfySecret}";
auth-file = "/var/lib/ntfy-sh/user.db";
auth-default-access = "deny-all";
enable-login = true;
};
};
- systemd.services.ntfy-sh = {
+
+ services.nginx.enable = config.services.ntfy-sh.enable;
+
+ systemd.services.ntfy-sh = lib.mkIf config.services.ntfy-sh.enable {
serviceConfig = {
- EnvironmentFile = "/run/secrets/ntfy";
+ EnvironmentFile = "/run/secrets/${ntfySecret}";
};
postStart = lib.mkForce ''
# 1. Wait for the server to initialize the database
@@ -45,4 +58,22 @@
fi
'';
};
+
+ networking.domains.subDomains."${serverName}" = lib.mkIf config.services.ntfy-sh.enable { };
+ services.nginx.virtualHosts."${serverName}" = lib.mkIf config.services.ntfy-sh.enable {
+ serverName = "${serverName}";
+ enableACME = true;
+ forceSSL = true;
+ locations."/" = {
+ proxyPass = "http://127.0.0.1:${toString port}";
+ proxyWebsockets = true;
+ extraConfig = ''
+ proxy_buffering off;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ '';
+ };
+ };
}