blob: 979e96b4a5e83b22a0c43fba14e9d1b34ae62845 (
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
|
{
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 ];
}
|