Files
nixos/services/ntfy.nix

78 lines
1.6 KiB
Nix

# Module: services/ntfy
# Enables an ntfy server
{
config,
lib,
pkgs,
pkgsUnstable,
inputs,
...
}:
with lib;
let
cfg = config.ntfy;
ntfyHost = "127.0.0.1";
ntfyHttpPort = "8100";
ntfyPrometheusPort = "8101";
ntfyUrl = "https://ntfy.its-et.me";
ntfyCacheDir = "/var/lib/ntfy-sh";
ntfyLibDir = "/var/lib/ntfy-sh";
in
{
options.ntfy = {
enable = mkEnableOption "Enables ntfy module";
};
config = mkIf cfg.enable {
services.ntfy-sh = {
enable = true;
package = pkgsUnstable.ntfy-sh;
settings = {
base-url = ntfyUrl;
listen-http = "${ntfyHost}:${ntfyHttpPort}";
cache-file = "${ntfyCacheDir}/cache.db";
cache-duration = "24h";
cache-batch-size = 0;
cache-batch-timeout = "0ms";
auth-file = "${ntfyLibDir}/users.db";
auth-default-access = "deny-all";
behind-proxy = true;
attachment-cache-dir = "${ntfyCacheDir}/attachments";
attachment-total-size-limit = "1G";
attachment-file-size-limit = "15M";
attachment-expiry-duration = "8h";
upstream-base-url = "https://ntfy.sh";
enable-metrics = true;
metrics-listen-http = ":${ntfyPrometheusPort}";
log-level = "info";
log-format = "text";
};
};
services.traefik.dynamicConfigOptions = {
http.routers.ntfy = {
entrypoints = [ "websecure" ];
rule = "Host(`ntfy.its-et.me`)";
tls.certresolver = "production";
service = "ntfy";
};
http.services.ntfy.loadbalancer.servers = [
{
url = "http://${ntfyHost}:${ntfyHttpPort}";
}
];
};
};
}