flake: autoupdate 2026-05-15T12-48-16Z

This commit is contained in:
2026-05-15 14:48:23 +02:00
parent 5bb9785a60
commit cc2e44afef
5 changed files with 71 additions and 3 deletions
@@ -0,0 +1,40 @@
{
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")
git -C "$FLAKE_DIR" pull
git -C "$FLAKE_DIR" tag "pre-autoupdate-$TIME"
nix flake update --flake "$FLAKE_DIR"
if sudo nixos-rebuild switch --flake "$FLAKE"; then
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 OK"
else
notify-send -u critical "Flake autoupdate" "FAILED"
matrix-commander-rs -m "Flake rebuild FAILED"
git reset --hard "pre-autoupdate-$TIME"
fi
'';
}
@@ -0,0 +1,21 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "custom-checkMatrix";
runtimeInputs = [
pkgs.matrix-commander-rs
pkgs.libnotify
];
text = ''
expected="@totorile1:unredacted.org"
current="$(matrix-commander-rs --whoami | tr -d '\n')"
if [ "$current" != "$expected" ]; then
notify-send "matrix-commander-rs" \
"You are not logged in as @totorile1:unredacted.org\nLog:\n$current"
fi
'';
}