Add telegram notifications

This commit is contained in:
Andreas Zweili 2022-08-27 16:30:54 +02:00
parent 5030f8fecd
commit 7dcd542904
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
{ custom, inputs, pkgs, ... }:
let
telegram-notify-env = "/home/${custom.username}/.nixos/secrets/passwords/telegram_notify_env";
telegram = pkgs.writeShellScriptBin "telegram" ''
export $(${pkgs.gnugrep}/bin/grep -v '^#' ${telegram-notify-env} | ${pkgs.findutils}/bin/xargs)
URL="https://api.telegram.org/bot$TELEGRAM_KEY/sendMessage"
curl -s -d "chat_id=$CHAT_ID&disable_web_page_preview=1&text=$1" $URL > /dev/null
'';
in
{
environment.systemPackages = with pkgs;
[
telegram
];
}