d8bceae6e8
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
1.3 KiB
Nix
58 lines
1.3 KiB
Nix
# self-hosted push notification server (ntfy)
|
|
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.my.profiles.ntfy;
|
|
hostName = config.networking.hostName;
|
|
in
|
|
{
|
|
options.my.profiles.ntfy = with lib; {
|
|
enable = mkEnableOption "ntfy notification server";
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 2586;
|
|
description = "HTTP port ntfy listens on.";
|
|
};
|
|
|
|
topic = mkOption {
|
|
type = types.str;
|
|
default = "ha";
|
|
description = "Topic Home Assistant publishes notifications to.";
|
|
};
|
|
|
|
haIntegration.enable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = "Wire a Home Assistant rest_command that publishes to ntfy.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
services.ntfy-sh = {
|
|
enable = true;
|
|
settings = {
|
|
base-url = "http://${hostName}:${toString cfg.port}";
|
|
listen-http = ":${toString cfg.port}";
|
|
auth-file = "/var/lib/ntfy-sh/user.db";
|
|
auth-default-access = "deny-all";
|
|
};
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [ cfg.port ];
|
|
|
|
my.homepage.services = [
|
|
{
|
|
group = "Services";
|
|
name = "ntfy";
|
|
description = "Push notifications";
|
|
href = "http://${hostName}:${toString cfg.port}";
|
|
icon = "ntfy.svg";
|
|
}
|
|
];
|
|
};
|
|
}
|