Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion home/dot_config/systemd/user/follow-main.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=Follow main: dotfiles through chezmoi, then Verk through its installer
Description=Follow main: dotfiles through chezmoi, then Heldra through its installer
After=network-online.target

[Service]
Expand Down
32 changes: 18 additions & 14 deletions home/dot_local/bin/executable_follow-main.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env sh
# Keep a Linux workstation (evo-dev) on the tip of main without a person at
# the keyboard: dotfiles through chezmoi, then Verk through its own guarded
# the keyboard: dotfiles through chezmoi, then Heldra through its own guarded
# installer. Run by follow-main.timer (~/.config/systemd/user); by hand:
# follow-main.sh # both
# follow-main.sh dotfiles # or: verk
# follow-main.sh dotfiles # or: heldra
# Nothing here forces anything. A dirty or non-master dotfiles checkout is
# reported and left alone, and Verk's install-linux.sh refuses under a
# reported and left alone, and Heldra's install-linux.sh refuses under a
# running chat turn (exit 3) or another install (exit 4); the next tick tries
# again. Logs: journalctl --user -u follow-main.
set -eu
Expand All @@ -32,32 +32,36 @@ dotfiles() {
fi
}

verk() {
repo="$HOME/code/verk"
[ -d "$repo/.git" ] || return 0
heldra() {
repo="$HOME/code/struktly/heldra"
[ -e "$repo/.git" ] || return 0
if [ -n "$(git -C "$repo" status --porcelain)" ]; then
echo "verk: $repo has local changes; not pulling" >&2
echo "heldra: $repo has local changes; not pulling" >&2
return 0
fi
if [ "$(git -C "$repo" branch --show-current)" != main ]; then
echo "heldra: $repo is not on main; not pulling" >&2
return 0
fi
git -C "$repo" pull -q --ff-only
head=$(git -C "$repo" rev-parse HEAD)
if [ "$head" = "$(cat "$HOME/.verk/installed.commit" 2>/dev/null)" ]; then
if [ "$head" = "$(cat "$HOME/.heldra/installed.commit" 2>/dev/null)" ]; then
return 0
fi
echo "verk: installing $head"
echo "heldra: installing $head"
# Builds go through Depot's cache; mise supplies the pinned Go and Bun.
rc=0
(cd "$repo" && mise exec -- depot exec -- ./scripts/install-linux.sh) || rc=$?
case $rc in
0) ;;
3 | 4) echo "verk: install refused (exit $rc); trying again next tick" ;;
*) echo "verk: install failed (exit $rc)" >&2; return "$rc" ;;
3 | 4) echo "heldra: install refused (exit $rc); trying again next tick" ;;
*) echo "heldra: install failed (exit $rc)" >&2; return "$rc" ;;
esac
}

case $what in
all) dotfiles; verk ;;
all) dotfiles; heldra ;;
dotfiles) dotfiles ;;
verk) verk ;;
*) echo "usage: follow-main.sh [all|dotfiles|verk]" >&2; exit 2 ;;
heldra) heldra ;;
*) echo "usage: follow-main.sh [all|dotfiles|heldra]" >&2; exit 2 ;;
esac
Loading