aboutsummaryrefslogtreecommitdiff
path: root/hosts/sagittarius
diff options
context:
space:
mode:
authorIsabella Bastaja <isabella@sorre.xyz>2026-08-16 21:34:04 +0200
committerIsabella Bastaja <isabella@sorre.xyz>2026-08-16 21:34:24 +0200
commitc4251be49fbb5023b0cefccff07914d3e9f6091e (patch)
treeb0c26365ebe666046dc9c1c1b6b85ff142f506e4 /hosts/sagittarius
parent2654bf4cd8aef09b1f4c84ae73294224faaee5b4 (diff)
auto-update: refactor, use snake case for variables
Diffstat (limited to 'hosts/sagittarius')
-rw-r--r--hosts/sagittarius/auto-update.nix27
1 files changed, 14 insertions, 13 deletions
diff --git a/hosts/sagittarius/auto-update.nix b/hosts/sagittarius/auto-update.nix
index fbc7dae..c1c4aae 100644
--- a/hosts/sagittarius/auto-update.nix
+++ b/hosts/sagittarius/auto-update.nix
@@ -31,45 +31,46 @@ in
#!/bin/sh
set -eu
- SRCREPO="$1"
- if [ -z "$SRCREPO" ]; then
+ SRC_REPO="$1"
+ if [ -z "$SRC_REPO" ]; then
echo "Error: git repository source was not provided." >&2
exit 1
fi
- TEMPDIR="$(mktemp --directory)"
- git clone --depth 1 "$SRCREPO" "$TEMPDIR"
+ TEMP_DIR="$(mktemp --directory)"
+ git clone --depth 1 "$SRC_REPO" "$TEMP_DIR"
- pushd "$TEMPDIR"
+ pushd "$TEMP_DIR"
TAGS="$(git tag --sort tag --list 'v*')"
- LATESTTAG="$(echo "$TAGS" | tail --lines 1)"
+ LATEST_TAG="$(echo "$TAGS" | tail --lines 1)"
- if [ -z "$LATESTTAG" ]; then
+ if [ -z "$LATEST_TAG" ]; then
echo "Error: no release tags defined." >&2
exit 1
fi
- git fetch "$SRCREPO" "$LATESTTAG"
+ git fetch "$SRC_REPO" "$LATEST_TAG"
git checkout FETCH_HEAD
CURRENT_REV="$(git rev-parse HEAD)"
- mkdir -p /var/lib/auto-update/
+ STATE_DIR="/var/lib/auto-update"
+ [ -d "$STATE_DIR" ] || mkdir -p "$STATE_DIR"
- if [ -e /var/lib/auto-update/last-commit ]; then
- LAST_REV="$(cat /var/lib/auto-update/last-commit)"
+ if [ -e "$STATE_DIR/last-commit" ]; then
+ LAST_REV="$(cat "$STATE_DIR/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
+ echo -n "$CURRENT_REV" > "$STATE_DIR/last-commit"
nixos-rebuild switch --flake .#
popd
- rm -rf "$TEMPDIR"
+ rm -rf "$TEMP_DIR"
'';
scriptArgs = "${configRepoSource}";
};