Add telegram notifications
This commit is contained in:
parent
5030f8fecd
commit
7dcd542904
|
@ -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
|
||||
];
|
||||
}
|
Loading…
Reference in New Issue