{ pkgs, ... }: pkgs.writeShellApplication { name = "custom-autoupdate"; runtimeInputs = with pkgs; [ git nixos-rebuild matrix-commander-rs libnotify ]; text = '' set -e FLAKE_DIR="/home/tomasr/nixos" FLAKE="$FLAKE_DIR#laptop" TIME=$(date -u +"%Y-%m-%dT%H-%M-%SZ") ERROR_FILE=$(mktemp) if sudo nixos-rebuild switch --flake "$FLAKE" 2> "$ERROR_FILE"; then git -C "$FLAKE_DIR" restore . git -C "$FLAKE_DIR" add flake.lock git -C "$FLAKE_DIR" commit -m "flake: autoupdate $TIME" git -C "$FLAKE_DIR" push notify-send "Flake autoupdate" "Rebuild OK" matrix-commander-rs -m "Flake rebuild succesfull.
@notificationbot_0000" \ --html \ -r "\!7j-78_02dHROeLj4Ns8F12eo4IiZGv4zNsQ_1-WlyIU" else ERROR_MSG=$(cat "$ERROR_FILE") notify-send -u critical "Flake autoupdate" "FAILED" matrix-commander-rs -m "Flake rebuild failed.
Error:
$ERROR_MSG

@notificationbot_0000" \ --html \ -r "\!7j-78_02dHROeLj4Ns8F12eo4IiZGv4zNsQ_1-WlyIU" git -C "$FLAKE_DIR" reset --hard "pre-autoupdate-$TIME" fi rm -f "$ERROR_FILE" ''; }