no-mistakes(review): always install latest backpass and acpx on rebuild

This commit is contained in:
Lap Tran committed 2026-11-11 12:39:56 -05:00
1 parent d4e8c24b2f
commit 9addc502fa
1 file changed
+16 -14
+16 -14
View File
@@ -387,10 +387,12 @@ in
# never Nix's npm (EACCES on the store). Both track the registry's latest on # never Nix's npm (EACCES on the store). Both track the registry's latest on
# every rebuild: for each package the installed version is compared with the # every rebuild: for each package the installed version is compared with the
# published one, and an install runs only when they differ, so a current copy # published one, and an install runs only when they differ, so a current copy
# is left alone and a stale one converges. The registry lookup and the install # is left alone and a stale one converges. The switch therefore always brings
# are optional steps - a failure there warns and the switch continues. A # both packages to the latest published version, whether or not a process of
# package with a live process is never replaced mid-session: that switch skips # that package is running: a running process keeps the code it already loaded
# it and names the follow-up. # and picks the new version up at its next start, so the switch prints that as
# a notice and still installs. The registry lookup and the install are optional
# steps - a failure there warns and the switch continues.
home.activation.backpass = lib.hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.backpass = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
set -euo pipefail set -euo pipefail
# Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node` # Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node`
@@ -403,17 +405,13 @@ in
exit 1 exit 1
fi fi
# Converge one npm global to the registry's latest. $1 is the package name, # Converge one npm global to the registry's latest. $1 is the package name,
# $2 is the pgrep pattern that identifies a live process of that package. # $2 is the pgrep pattern that identifies a live process of that package,
# The running-process guard comes first, because an install rewrites the # used only to explain that a live process keeps its loaded code. Every
# package directory under a running process. Every optional failure returns # optional failure returns 0, so `set -e` never aborts the switch and later
# 0, so `set -e` never aborts the switch and later blocks still run. # blocks still run.
converge_npm_global() { converge_npm_global() {
pkg="$1" pkg="$1"
live="$2" live="$2"
if pgrep -f "$live" >/dev/null 2>&1; then
echo "$pkg: $pkg is running - leaving the installed copy untouched. Finish or stop it, then rerun the rebuild to update." >&2
return 0
fi
# Installed version from npm's own global record; empty means absent. The # Installed version from npm's own global record; empty means absent. The
# `|| true` keeps `set -e` quiet when npm exits non-zero over extraneous # `|| true` keeps `set -e` quiet when npm exits non-zero over extraneous
# packages. # packages.
@@ -427,8 +425,7 @@ in
fi fi
if [ "$installed" = "$latest" ]; then if [ "$installed" = "$latest" ]; then
echo "$pkg: already at $latest" echo "$pkg: already at $latest"
return 0 else
fi
current="$installed" current="$installed"
[ -n "$current" ] || current=none [ -n "$current" ] || current=none
echo "$pkg: updating $current -> $latest" echo "$pkg: updating $current -> $latest"
@@ -437,6 +434,11 @@ in
echo "$pkg: installed $latest" echo "$pkg: installed $latest"
else else
echo "$pkg: install of $latest failed - keeping the installed copy, rebuild continues" >&2 echo "$pkg: install of $latest failed - keeping the installed copy, rebuild continues" >&2
return 0
fi
fi
if pgrep -f "$live" >/dev/null 2>&1; then
echo "$pkg: a running process keeps the code it already loaded - $latest takes effect at its next start" >&2
fi fi
} }
converge_npm_global backpass "node_modules/backpass/bin/backpass.js" converge_npm_global backpass "node_modules/backpass/bin/backpass.js"