aboutsummaryrefslogtreecommitdiff
path: root/hosts
diff options
context:
space:
mode:
authorIsabella Bastaja <isabella@sorre.xyz>2026-08-16 20:27:39 +0200
committerIsabella Bastaja <isabella@sorre.xyz>2026-08-16 20:31:57 +0200
commitf1e02897eb114e054bb356730f8420b18125d5eb (patch)
tree628e42c342f08aab5b11dfb211fbb4eed59f664d /hosts
parentda49fea0f228e6113039a93e25ace7a73e967b63 (diff)
sagittarius: skip auto update when already on the right commitv0.1.2
Diffstat (limited to 'hosts')
-rw-r--r--hosts/sagittarius/auto-update.nix16
1 files changed, 14 insertions, 2 deletions
diff --git a/hosts/sagittarius/auto-update.nix b/hosts/sagittarius/auto-update.nix
index 4e8c2ac..fbc7dae 100644
--- a/hosts/sagittarius/auto-update.nix
+++ b/hosts/sagittarius/auto-update.nix
@@ -29,7 +29,7 @@ in
enableStrictShellChecks = true;
script = ''
#!/bin/sh
- set -xeu
+ set -eu
SRCREPO="$1"
if [ -z "$SRCREPO" ]; then
@@ -43,7 +43,7 @@ in
pushd "$TEMPDIR"
TAGS="$(git tag --sort tag --list 'v*')"
- LATESTTAG="$(echo "$TAGS" | head --lines 1)"
+ LATESTTAG="$(echo "$TAGS" | tail --lines 1)"
if [ -z "$LATESTTAG" ]; then
echo "Error: no release tags defined." >&2
@@ -53,6 +53,18 @@ in
git fetch "$SRCREPO" "$LATESTTAG"
git checkout FETCH_HEAD
+ CURRENT_REV="$(git rev-parse HEAD)"
+ mkdir -p /var/lib/auto-update/
+
+ if [ -e /var/lib/auto-update/last-commit ]; then
+ LAST_REV="$(cat /var/lib/auto-update/last-commit)"
+ if [ "$CURRENT_REV" = "$LAST_REV" ]; then
+ echo "System is already up to date. Exiting." >&2
+ exit 0
+ fi
+ fi
+ echo -n "$CURRENT_REV" > /var/lib/auto-update/last-commit
+
nixos-rebuild switch --flake .#
popd