diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-05 13:53:09 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-05 13:53:09 +0300 |
| commit | 611dfd90d4e523984a78728ebfee033e4c16b37d (patch) | |
| tree | 682e459c78f5a994c276f7021ceda390de49ec6e /link | |
| parent | fac95146b95ef103e8100b2284671be4bdc1065f (diff) | |
pi: extensions as a directory of links, so a machine can have its own
~/.pi/agent/extensions was a link to the repo's directory, so anything that
installs a pi extension wrote into this checkout -- herdr's pi integration did,
on one machine. It is now a real directory with the repo's tracked extensions
linked in one by one, and a file a machine adds there stays that machine's.
pi follows the links, and skips a dangling one silently, so an extension
deleted from the repo leaves a harmless stale link.
The old directory link is removed first: linking into it would write through
to the repo and turn its files into links to themselves. Only tracked files are
linked, so a machine's leftovers in the repo's directory are not linked back.
The filed version put this loop in link.sh; it lives in link/pi.sh, since
link.sh holds one-line links only and a part also obeys ~/.config/dot/skip.
From change request 3f6b05.
Diffstat (limited to 'link')
| -rwxr-xr-x | link/pi.sh | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -1,6 +1,7 @@ #!/bin/bash -# pi's settings.json, generated. Dry run by default; pass `yes` to apply. +# pi's extensions directory, and its settings.json and models.json, generated. +# Dry run by default; pass `yes` to apply. set -euo pipefail @@ -40,6 +41,36 @@ then exit 0 fi +# pi's extensions: a real directory, with this repo's tracked extensions linked +# in one by one, so an extension only one machine has -- herdr's pi integration +# writes herdr-agent-state.ts here -- sits beside them instead of landing in this +# checkout. pi loads every *.ts and *.js there and follows links, and it skips a +# dangling one silently (resource-loader.js, pi 1.0.0), so the link left behind +# by an extension deleted from the repo does no harm. +# +# Machines used to link the whole directory to the repo. That link goes first: +# linking into it would write through to the repo and turn its files into links +# to themselves. Tracked files only, so nothing a machine left in the repo's +# directory is linked back in. +pi_extensions="$pi_dir/extensions" +if [[ -L "$pi_extensions" ]] +then + if [[ -n "${is_dry_run}" ]] + then + yellow "$pi_extensions is a link to the repo; will become a directory of links to its tracked files" + else + rm "$pi_extensions" + fi +fi +if [[ ! -L "$pi_extensions" ]] +then + [[ -n "${is_dry_run}" ]] || mkdir -p "$pi_extensions" + while IFS= read -r -d '' f + do + link "$dotfiles_dir/$f" "$pi_extensions/$(basename "$f")" + done < <(git -C "$dotfiles_dir" ls-files -z -- config/pi/extensions) +fi + pi_status="$(DRY_RUN="$is_dry_run" python3 "$dotfiles_dir/link/pi-settings.py" \ "$config_dir/pi/settings.json" \ "$xdg_config_dir/pi/settings.d" \ |
