Hook points
Your provision hook clones the repo. To put an SSH config, credential helper, or insteadOf rewrite in place before it runs, add a provision:before hook to a layer:
cat > .paraspace/layers/project/hooks/provision:before <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
git config --global url."git@github.com:".insteadOf https://github.com/
EOFWhen para runs provision, it first runs all provision:before hooks, then all provision hooks, then all provision:after hooks. Within each group, it runs hooks in stack order, starting with the top layer.
The same sequence applies to boot, image-build, and custom hooks called through "$PARA_RUN_HOOK". If a provision:before hook fails, para stops before running any provision hooks.
Run hooks before a specific operation
To run hooks immediately before cloning, add this call before the clone command:
# .paraspace/layers/project/hooks/provision
"$PARA_RUN_HOOK" clone:beforeThis runs every clone:before hook at that point in the script. Custom hook points need no registration.
Define hooks/clone:before in any layer that needs to run code before cloning:
cat > .paraspace/layers/project/hooks/clone:before <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
git config --global url."git@github.com:".insteadOf https://github.com/
EOFIf several layers define the same hook, para runs each implementation in stack order, starting with the top layer. This also applies to provision and boot. Keep each implementation independent so it works with different layer stacks.
Naming
para does not add another set of before/after calls to hooks whose names already end in :before or :after. For example, running provision:before does not trigger provision:before:before or provision:before:after.
provision, boot, and image-build are para's names. Every other name in hooks/ is yours.
Pass data between hooks
Hooks run in separate processes. When passing data between them:
Export variables needed by a called hook. An assignment such as
repo_url=…is not available to child processes unless exported. Use a file for values that must persist after the hook finishes.Pass required variables when switching users.
su -andsudocan remove variables from the environment. For example:shsu - "$PARA_USER" -c "PARA_LAYER_DIR=$PARA_LAYER_DIR install-my-dotfiles"Don't re-source
~/.paraspace/envinside a hook. It unsets$PARA_LAYER_DIRand$PARA_HOOK_CHAIN, removing the layer path and the call history used to detect recursion.
Reading a failure
para reports failures at each level of a nested hook call when hooks use set -e:
error: hook failed (exit 7): project/hooks/keys:setup
chain: provision > clone:before > keys:setup
error: hook failed (exit 7): project/hooks/clone:before
chain: provision > clone:before
error: hook failed (exit 7): project/hooks/provisionThe first error identifies the failing hook. Its chain: shows the nested calls that reached it. Later errors identify the callers that also failed. Automatic before/after calls appear in the chain alongside explicit hook calls.
para returns the failing hook's exit status.
Start hooks with set -euo pipefail, as the generated stubs do. Without set -e or explicit error handling, a hook can continue after a failed "$PARA_RUN_HOOK" call and exit zero. para up would then report the workspace as ready despite the failure.
para rejects recursive hook calls:
error: hook cycle: provision > clone:before > provisionSequential calls to the same hook are allowed. If you call boot:after from inside a boot hook, para runs the matching hooks at that call and again after all boot hooks finish.