2023-09-25 16:56:41 +00:00
|
|
|
# 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;
|
2023-09-26 14:48:54 +00:00
|
|
|
default = false;
|
2023-09-25 16:56:41 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-17 15:47:47 +00:00
|
|
|
sandbox.method = "bwrap";
|
|
|
|
sandbox.wrapperType = "wrappedDerivation";
|
|
|
|
sandbox.net = "clearnet";
|
|
|
|
|
2023-09-25 16:56:41 +00:00
|
|
|
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)
|
2023-09-26 13:52:10 +00:00
|
|
|
ntfy sub "https://ntfy.uninsane.org:2587/$topic"
|
2023-09-25 16:56:41 +00:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "20s";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|