diff --git a/nix/scripts/build-root.sh b/nix/scripts/build-root.sh index 0a8240e..2fba0a7 100644 --- a/nix/scripts/build-root.sh +++ b/nix/scripts/build-root.sh @@ -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 } diff --git a/nix/scripts/gateway-install.sh b/nix/scripts/gateway-install.sh index e3d26b5..712d256 100755 --- a/nix/scripts/gateway-install.sh +++ b/nix/scripts/gateway-install.sh @@ -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