Speed up gateway build-root cleanup

Move the temporary output build root out of the final output instead of recursively deleting it during install, and time the final wrapper/cleanup steps so Garnix logs show where gateway builds stall.

Tests: sh -n nix/scripts/build-root.sh nix/scripts/gateway-install.sh; git diff --check; nix build --dry-run .#checks.aarch64-darwin.qmd-runtime .#checks.x86_64-linux.qmd-runtime --accept-flake-config
This commit is contained in:
joshp123 2026-05-06 12:51:50 +02:00
parent cb9ec56612
commit 87f883a6c8
2 changed files with 11 additions and 3 deletions

View File

@ -73,6 +73,14 @@ openclaw_cleanup_output_build_root() {
openclaw_cleanup_output_pnpm_store
case "$build_root" in
"$out"/*) rm -rf "$build_root" ;;
"$out"/*)
if [ -n "${NIX_BUILD_TOP:-}" ] && [ -d "$NIX_BUILD_TOP" ]; then
discard="$NIX_BUILD_TOP/.openclaw-build-root-discard-$$"
if mv "$build_root" "$discard" 2>/dev/null; then
return 0
fi
fi
rm -rf "$build_root"
;;
esac
}

View File

@ -140,8 +140,8 @@ fi
log_step "validate node_modules symlinks" check_no_broken_symlinks "$out/lib/openclaw/node_modules"
bash -e -c '. "$STDENV_SETUP"; makeWrapper "$NODE_BIN" "$out/bin/openclaw" --add-flags "$out/lib/openclaw/dist/index.js" --set-default OPENCLAW_NIX_MODE "1"'
log_step "wrap openclaw" bash -e -c '. "$STDENV_SETUP"; makeWrapper "$NODE_BIN" "$out/bin/openclaw" --add-flags "$out/lib/openclaw/dist/index.js" --set-default OPENCLAW_NIX_MODE "1"'
if [ -n "${OPENCLAW_BUILD_ROOT_SH:-}" ]; then
openclaw_cleanup_output_build_root
log_step "discard build root" openclaw_cleanup_output_build_root
fi