blob: b67771c0c736c409160c40e2202b976f0f3ab7f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# modules/scripts/pushover/default.nix
#
# Send notifications via the pushover API.
{
inputs,
config,
pkgs,
...
}:
let
pushover = pkgs.writeShellScriptBin "pushover" ''
set -e
APP=$(cat ${config.age.secrets.pushoverAppToken.path})
USER=$(cat ${config.age.secrets.pushoverUserToken.path})
while getopts ":t:" args; do
case "$args" in
t)
TITLE="$OPTARG"
;;
:)
echo "missing option argument for -$OPTARG" >&2
exit 1
;;
*)
echo "invalid option -$OPTARG" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
MESSAGE="$*"
if [ -z "$MESSAGE" ] || [ "$MESSAGE" = " " ]; then
MESSAGE="No errors to report."
fi
/run/current-system/sw/bin/curl -s \
--form-string "token=$APP" \
--form-string "user=$USER" \
--form-string "title=$TITLE" \
--form-string "message=$MESSAGE" \
https://api.pushover.net/1/messages.json
'';
in
{
age.secrets = {
pushoverAppToken.file = "${inputs.self}/secrets/pushoverAppToken.age";
pushoverUserToken.file = "${inputs.self}/secrets/pushoverUserToken.age";
};
environment.systemPackages = [ pushover ];
}
|