nix-files/hosts/common/programs/ntfy-sh.nix
2024-02-17 15:47:47 +00:00

44 lines
1.1 KiB
Nix

# notification system, used especially to remotely wake moby
# source: <https://github.com/binwiederhier/ntfy>
# docs: <https://docs.ntfy.sh/>
#
# send a test notification with:
# - `ntfy pub "https://ntfy.uninsane.org/$(cat ~/.config/ntfy-sh/topic)" test`
{ config, lib, ... }:
let
cfg = config.sane.programs.ntfy-sh;
in
{
sane.programs.ntfy-sh = {
configOption = with lib; mkOption {
default = {};
type = types.submodule {
options.autostart = mkOption {
type = types.bool;
default = false;
};
};
};
sandbox.method = "bwrap";
sandbox.wrapperType = "wrappedDerivation";
sandbox.net = "clearnet";
secrets.".config/ntfy-sh/topic" = ../../../secrets/common/ntfy-sh-topic.bin;
services.ntfy-sub = {
description = "listen for push-notifications";
wantedBy = lib.mkIf cfg.config.autostart [ "default.target" ];
script = ''
topic=$(cat ~/.config/ntfy-sh/topic)
ntfy sub "https://ntfy.uninsane.org:2587/$topic"
'';
serviceConfig = {
Type = "simple";
Restart = "always";
RestartSec = "20s";
};
};
};
}