Script recipes
Some tools only ship a curl … | sh installer or need a source build. Script
recipes cover them, safely.
42space recipe new mytool --version 1.2 # template, pre-filled with matching journal commands
$EDITOR ~/.config/42space/scripts/mytool.sh
42space recipe approve mytool # shows the script (or a diff), asks, then installs
42space recipe list
The script runs with sh -e in an empty scratch directory and gets:
| Variable | Meaning |
|---|---|
$PREFIX | install everything here; bin/ is exposed on PATH |
$VERSION | the version from the recipe |
$WORK | scratch directory, deleted afterwards |
$CACHE | machine-local cache directory |
Approval
A script runs only if its exact sha256 is approved, and any edit needs a new
approval. Approvals live in ~/.local/state/42space, outside the
git-synced repo, so a pulled commit can never approve itself. One approval
covers all your machines. Scripts that call sudo, su, pkexec or doas
are refused.
Each script revision installs into its own directory, so a failing edit never destroys the last good install.
Example: nvm without curl | bash
nvm's installer writes to ~/.nvm and edits your rc files. As a recipe it
lives in goinfre instead, and expose.lazy defines a stub that loads nvm.sh
on first use, so shells don't get slower:
name = "nvm"
version = "0.41.0"
strategy = "script"
script = "scripts/nvm.sh"
[expose.lazy]
nvm = "{prefix}/load.sh"
[expose.env]
NVM_DIR = "{cache}/nvm"
git clone --quiet --depth 1 --branch "v$VERSION" https://github.com/nvm-sh/nvm.git "$WORK/nvm"
cp -R "$WORK/nvm/." "$PREFIX/" && rm -rf "$PREFIX/.git"
mkdir -p "$CACHE/nvm"
# nvm refuses to run with a global npm prefix; drop it only in shells that use nvm
printf 'unset NPM_CONFIG_PREFIX npm_config_prefix\n. "%s/nvm.sh"\n' "$PREFIX" > "$PREFIX/load.sh"