feat: installer boots nvim once and restores the lazy-lock pins

A first nvim start cloned the later-round plugins (claudecode, mini.*,
nvim-lint, friendly-snippets, ...) at branch tip and rewrote the seeded
lazy-lock.json with the tips. The install pipeline now ends with a headless
first boot, puts the seeded lockfile back, and runs `Lazy! restore`. It runs
only where lazy has never installed a plugin, so a lockfile the user has
moved on is never touched, and a second run does nothing.
This commit is contained in:
bcherb2 committed 2026-11-18 02:29:35 -05:00
1 parent 4e2452e994
commit e0c78a3ffa
5 files changed
+121

No files matched your search

+39
View File
@@ -1219,6 +1219,44 @@ herdr_integrations() {
done
}
# nvim's first boot, done here so the lazy-lock.json pins survive it.
#
# The config seeds lazy-lock.json (a create_ file). On a first start lazy.nvim
# installs most plugins at their pins, but the ones that join in a later
# bootstrap round (claudecode, mini.*, nvim-lint, friendly-snippets, ...) are
# cloned at branch tip, and lazy then rewrites the lockfile with the tips. The
# pins are gone after the one boot meant to honor them. So the installer does
# that boot headless, puts the seeded lockfile back, and `Lazy! restore`s every
# plugin to it.
#
# The gate is "lazy has never installed a plugin here": no plugin directory.
# That is also what proves the lockfile on disk is the seed (or one written by
# hand), never one lazy rewrote. A lockfile moved on by `:Lazy update` sits
# beside a plugin directory and is left alone. The directory this step creates
# is its own stamp, so a second run does nothing.
nvim_first_boot() {
have nvim || return 0
nb_lock=${XDG_CONFIG_HOME:-$HOME/.config}/nvim/lazy-lock.json
nb_lazy=${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lazy
[ -f "$nb_lock" ] || return 0
[ ! -e "$nb_lazy" ] || return 0
NVIM=$(find_tool nvim)
workdir || return 0
nb_seed=$WORKDIR/lazy-lock.seed.json nb_log=$WORKDIR/nvim-first-boot.log
head_ "nvim plugins, pinned to lazy-lock.json"
run_sh "cp '$nb_lock' '$nb_seed'" || { warn "could not save the seeded lazy-lock.json"; return 0; }
if ! run_sh "'$NVIM' --headless +qa </dev/null >'$nb_log' 2>&1"; then
warn "nvim's first boot failed -- restoring the pins anyway"
[ -r "$nb_log" ] && tail -n 20 "$nb_log" >&2
fi
run_sh "cp '$nb_seed' '$nb_lock'" || { warn "could not put the seeded lazy-lock.json back"; return 0; }
run_sh "'$NVIM' --headless '+Lazy! restore' +qa </dev/null >'$nb_log' 2>&1" && return 0
warn "Lazy! restore failed -- plugins may not match lazy-lock.json. Retry with:"
warn " nvim --headless '+Lazy! restore' +qa"
[ -r "$nb_log" ] && tail -n 20 "$nb_log" >&2
return 0
}
cmd_install() {
# A cron job re-running `--unattended install` gets its SAVED selection --
# that contract stands. But on a box where nothing was ever chosen,
@@ -1279,6 +1317,7 @@ cmd_install() {
install_npm "$(col npm)"
install_uv "$(col uv)"
herdr_integrations
nvim_first_boot
rm -f "$tbl"
if [ -s "$FAILED" ]; then