Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions overlays/default.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{ inputs }:
let
# Override clawdbot source to v2026.1.16-2
# Override clawdbot source to v2026.1.20
clawdbotSourceOverride = {
owner = "clawdbot";
repo = "clawdbot";
rev = "be37b39782e0799ba5b9533561de6d128d50c863";
hash = "sha256-y1ToqEcfl0yVAJkVld0k5AX5tztiE7yJt/F7Rhg+dAc=";
pnpmDepsHash = "sha256-NPQrkhhvAoIYzR1gopqsErps1K/HkfxmrPXpyMlN0Bc=";
rev = "9a14267dfa5238188a30636bd60eed08f05a7255";
hash = "sha256-T44joLbbbEFmsdOA9Q6W5Fpq1+1BtRJOHAy7/p3CXls=";
pnpmDepsHash = "sha256-tGzKcCiZNlWlKMNNFmxcFpIvO92G9myhM+OYaGea4hw=";
};
# Override clawdbot-app to v2026.1.16-2 (fixes broken app package)
# Override clawdbot-app to v2026.1.20 (fixes broken app package)
clawdbotAppOverride = {
version = "2026.1.16-2";
url = "https://github.com/clawdbot/clawdbot/releases/download/v2026.1.16-2/Clawdbot-2026.1.16-2.zip";
hash = "sha256-CQDGFA+/2McVxIw7WXtJZgr6LmtWTy0Dks++pjdU4rU=";
version = "2026.1.20";
url = "https://github.com/clawdbot/clawdbot/releases/download/v2026.1.20/Clawdbot-2026.1.20.zip";
hash = "sha256-BQuZqiTgcshT/YUnEq4OS6RxvjeTFgpPhd2jrGmcZXk=";
};
in
[
Expand All @@ -22,7 +22,7 @@ in
(
final: prev:
let
clawdbotVersion = "2026.1.16-2";
clawdbotVersion = "2026.1.20";
basePkgs = import "${inputs.nix-clawdbot}/nix/packages" {
pkgs = prev;
sourceInfo = clawdbotSourceOverride;
Expand Down
69 changes: 61 additions & 8 deletions scripts/upgrade-overlays.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@ sed_inplace() {
fi
}

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compute_pnpm_deps_hash function lacks a comment or docstring explaining its purpose, how it works, and what it returns. Consider adding a header comment similar to other utility functions in the file to improve code documentation and maintainability.

Suggested change
# Compute the correct pnpmDepsHash for the overlay.
# This temporarily writes a fake pnpmDepsHash into $OVERLAY_FILE, runs a Nix
# build to trigger a hash mismatch, extracts the expected hash from the build
# error output, and then replaces the fake value with the correct hash.
# On success, updates pnpmDepsHash in the overlay file and returns 0.
# If the correct hash cannot be determined, restores the original value and
# returns 1.

Copilot uses AI. Check for mistakes.
compute_pnpm_deps_hash() {
local fake_hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
local current_hash

# Get current pnpmDepsHash
current_hash=$(grep 'pnpmDepsHash = "' "$OVERLAY_FILE" | head -1 | sed 's/.*pnpmDepsHash = "\([^"]*\)".*/\1/')

echo " Computing pnpmDepsHash (this requires a build attempt)..."

# Temporarily set fake hash
sed_inplace "s|pnpmDepsHash = \"[^\"]*\";|pnpmDepsHash = \"$fake_hash\";|" "$OVERLAY_FILE"

# Run nix build and capture the correct hash from error output
local build_output correct_hash
build_output=$(nix build ".#darwinConfigurations.aarch64-darwin.system" --no-link 2>&1 || true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The nix build command explicitly targets . #darwinConfigurations.aarch64-darwin.system. This hardcoded path makes the compute_pnpm_deps_hash function specific to aarch64-darwin systems. If this script is intended to be run on other architectures (e.g., x86_64-linux or aarch64-linux as defined in flake.nix), this command will likely fail or produce an irrelevant hash. Consider making the build target dynamic based on the current system or an argument, or add a check to ensure it's run on the correct architecture.

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build command is hardcoded to build specifically for aarch64-darwin, which may fail on non-aarch64-darwin systems. Consider detecting the system architecture or making the target configurable to support both aarch64-darwin and x86_64-darwin systems.

Copilot uses AI. Check for mistakes.

# Extract the correct hash from "got: sha256-..." line
correct_hash=$(echo "$build_output" | grep -o 'got:[[:space:]]*sha256-[A-Za-z0-9+/=]*' | head -1 | sed 's/got:[[:space:]]*//')

if [ -n "$correct_hash" ]; then
echo " pnpmDepsHash: $correct_hash"
sed_inplace "s|pnpmDepsHash = \"[^\"]*\";|pnpmDepsHash = \"$correct_hash\";|" "$OVERLAY_FILE"
return 0
else
# Restore original hash if we couldn't get a new one
log_warn " Could not determine pnpmDepsHash, restoring original"
sed_inplace "s|pnpmDepsHash = \"[^\"]*\";|pnpmDepsHash = \"$current_hash\";|" "$OVERLAY_FILE"
Comment on lines +109 to +112

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function assumes that if no hash is extracted from the build output, it should restore the original hash. However, this doesn't distinguish between a legitimate hash mismatch error and other types of build failures (e.g., network issues, syntax errors, missing dependencies). Consider adding validation to check if the build output contains a hash mismatch error before assuming the extraction failed, to provide more helpful error messages to users.

Copilot uses AI. Check for mistakes.
return 1
Comment on lines +86 to +113

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Scope pnpmDepsHash updates to clawdbotSourceOverride only.

Line 91 and Lines 96–112 use global grep/sed patterns that will update every pnpmDepsHash in overlays/default.nix. If other overlays add a pnpmDepsHash, this silently corrupts them. Also, with set -euo pipefail, a missing match will abort the script. Prefer scoping the read/write to the clawdbotSourceOverride block and explicitly error if the hash isn’t found.

🛠️ Proposed fix (scoped read/write + guard)
-  current_hash=$(grep 'pnpmDepsHash = "' "$OVERLAY_FILE" | head -1 | sed 's/.*pnpmDepsHash = "\([^"]*\)".*/\1/')
+  current_hash=$(awk '
+    /clawdbotSourceOverride = \{/ { in_src=1 }
+    in_src && /pnpmDepsHash = "/ {
+      match($0, /pnpmDepsHash = "([^"]+)"/, m)
+      print m[1]
+      exit
+    }
+    in_src && /\}/ { in_src=0 }
+  ' "$OVERLAY_FILE")
+  if [ -z "$current_hash" ]; then
+    log_error "  pnpmDepsHash not found in clawdbotSourceOverride"
+    return 1
+  fi
@@
-  sed_inplace "s|pnpmDepsHash = \"[^\"]*\";|pnpmDepsHash = \"$fake_hash\";|" "$OVERLAY_FILE"
+  awk -v new_hash="$fake_hash" '
+    /clawdbotSourceOverride = \{/ { in_src=1 }
+    in_src && /pnpmDepsHash = "sha256-/ {
+      sub(/pnpmDepsHash = "[^"]*"/, "pnpmDepsHash = \"" new_hash "\"")
+      in_src=0
+    }
+    { print }
+  ' "$OVERLAY_FILE" >"$OVERLAY_FILE.tmp" && mv "$OVERLAY_FILE.tmp" "$OVERLAY_FILE"
@@
-    sed_inplace "s|pnpmDepsHash = \"[^\"]*\";|pnpmDepsHash = \"$correct_hash\";|" "$OVERLAY_FILE"
+    awk -v new_hash="$correct_hash" '
+      /clawdbotSourceOverride = \{/ { in_src=1 }
+      in_src && /pnpmDepsHash = "sha256-/ {
+        sub(/pnpmDepsHash = "[^"]*"/, "pnpmDepsHash = \"" new_hash "\"")
+        in_src=0
+      }
+      { print }
+    ' "$OVERLAY_FILE" >"$OVERLAY_FILE.tmp" && mv "$OVERLAY_FILE.tmp" "$OVERLAY_FILE"
@@
-    sed_inplace "s|pnpmDepsHash = \"[^\"]*\";|pnpmDepsHash = \"$current_hash\";|" "$OVERLAY_FILE"
+    awk -v new_hash="$current_hash" '
+      /clawdbotSourceOverride = \{/ { in_src=1 }
+      in_src && /pnpmDepsHash = "sha256-/ {
+        sub(/pnpmDepsHash = "[^"]*"/, "pnpmDepsHash = \"" new_hash "\"")
+        in_src=0
+      }
+      { print }
+    ' "$OVERLAY_FILE" >"$OVERLAY_FILE.tmp" && mv "$OVERLAY_FILE.tmp" "$OVERLAY_FILE"
🤖 Prompt for AI Agents
In `@scripts/upgrade-overlays.sh` around lines 86 - 113, The
compute_pnpm_deps_hash function is currently using global grep/sed patterns that
will change every pnpmDepsHash in the overlay file; update it to first extract
the clawdbotSourceOverride block (e.g., locate the block start/end markers for
"clawdbotSourceOverride"), read the current pnpmDepsHash only from that block
(replace the current_hash extraction that uses grep on the whole file), perform
the temporary fake-hash insertion and the final sed replacement scoped to that
block (instead of global substitutions used in the sed_inplace calls), and if
the clawdbotSourceOverride block or its pnpmDepsHash key is not found, fail with
a clear error rather than proceeding (so the function returns non-zero). Ensure
you reference compute_pnpm_deps_hash, current_hash, build_output/correct_hash
and the sed_inplace usages when making these changes.

fi
}
Comment on lines +86 to +115

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the sed_inplace operation fails when setting the fake hash or restoring the original hash (lines 96, 107, or 112), the function will continue execution due to the 'set -euo pipefail' at the script level. However, a failure during hash restoration could leave the overlay file in an inconsistent state. Consider adding error checking after critical sed_inplace operations or wrapping the function in a trap to ensure the original hash is restored even if the function fails unexpectedly.

Copilot uses AI. Check for mistakes.

# --- Clawdbot upgrade ---

upgrade_clawdbot() {
Expand Down Expand Up @@ -155,24 +186,43 @@ upgrade_clawdbot() {
sed_inplace "s|# Override clawdbot source to v[^ ]*|# Override clawdbot source to v$version|" "$OVERLAY_FILE"
sed_inplace "s|# Override clawdbot-app to v[^ ]* |# Override clawdbot-app to v$version |" "$OVERLAY_FILE"

log_info "✅ clawdbot upgraded from $current_version to $version"
log_warn "⚠️ Note: pnpmDepsHash may need manual update after first build failure"
log_warn " Run 'make build' and check for hash mismatch errors"
# Update pnpmDepsHash automatically
if compute_pnpm_deps_hash; then
log_info "✅ clawdbot upgraded from $current_version to $version"
else
log_info "✅ clawdbot upgraded from $current_version to $version"
log_warn "⚠️ pnpmDepsHash may need manual verification"
fi
Comment on lines +190 to +195

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The success message "✅ clawdbot upgraded..." is printed twice, once inside the if block and once inside the else block. If compute_pnpm_deps_hash fails, the script still indicates a successful upgrade, which can be misleading. It would be better to print the success message only when the full upgrade, including hash computation, is successful. If compute_pnpm_deps_hash fails, a more distinct warning or error should be shown instead of a success message.

Suggested change
if compute_pnpm_deps_hash; then
log_info "✅ clawdbot upgraded from $current_version to $version"
else
log_info "✅ clawdbot upgraded from $current_version to $version"
log_warn "⚠️ pnpmDepsHash may need manual verification"
fi
# Update pnpmDepsHash automatically
if compute_pnpm_deps_hash; then
log_info "✅ clawdbot upgraded from $current_version to $version"
else
log_warn "⚠️ clawdbot upgraded from $current_version to $version, but pnpmDepsHash may need manual verification"
fi


Comment on lines +191 to +196

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The success message is displayed in both the if and else branches, making the conditional logic redundant. The only difference is the warning message in the else branch. Consider restructuring this to avoid the duplicate log_info call, such as displaying the success message once after the conditional, or making the messages more distinct.

Suggested change
log_info "✅ clawdbot upgraded from $current_version to $version"
else
log_info "✅ clawdbot upgraded from $current_version to $version"
log_warn "⚠️ pnpmDepsHash may need manual verification"
fi
:
else
log_warn "⚠️ pnpmDepsHash may need manual verification"
fi
log_info "✅ clawdbot upgraded from $current_version to $version"

Copilot uses AI. Check for mistakes.
echo ""
echo "📝 Review changes with 'git diff overlays/default.nix'"
}

# --- Main ---

update_pnpm_hash() {
log_info "📦 Updating pnpmDepsHash..."
if compute_pnpm_deps_hash; then
log_info "✅ pnpmDepsHash updated successfully"
else
log_error "❌ Failed to update pnpmDepsHash"
exit 1
fi
echo ""
echo "📝 Review changes with 'git diff overlays/default.nix'"
}

usage() {
echo "Usage: $0 <overlay|all>"
echo "Usage: $0 <overlay|all|pnpm-hash>"
echo ""
echo "Available overlays:"
echo " clawdbot - Upgrade clawdbot overlay to latest release"
echo " all - Upgrade all overlays"
echo "Available commands:"
echo " clawdbot - Upgrade clawdbot overlay to latest release"
echo " pnpm-hash - Update only pnpmDepsHash (after flake.lock changes)"
echo " all - Upgrade all overlays"
echo ""
echo "Examples:"
echo " $0 clawdbot"
echo " $0 pnpm-hash"
echo " $0 all"
}

Expand All @@ -190,6 +240,9 @@ main() {
clawdbot)
upgrade_clawdbot
;;
pnpm-hash)
update_pnpm_hash
;;
all)
upgrade_clawdbot
# Add more overlay upgrades here as needed:
Expand All @@ -199,7 +252,7 @@ main() {
usage
;;
*)
log_error "Unknown overlay: $target"
log_error "Unknown command: $target"

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message was changed from "Unknown overlay:" to "Unknown command:", but the corresponding test in spec/upgrade_overlays_spec.sh (line 45) expects "Unknown overlay: unknown-overlay". This change will cause existing tests to fail. The tests should be updated to match this change in error messaging.

Copilot uses AI. Check for mistakes.
echo ""
usage
exit 1
Expand Down
6 changes: 3 additions & 3 deletions spec/upgrade_overlays_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ End
It 'shows usage with --help flag'
When run bash "$SCRIPT" --help
The output should include 'Usage:'
The output should include 'Available overlays:'
The output should include 'Available commands:'
The status should be success
End

Expand All @@ -42,8 +42,8 @@ After 'cleanup'

It 'fails for unknown overlay'
When run bash "$SCRIPT" unknown-overlay
The output should include 'Unknown overlay: unknown-overlay'
The output should include 'Available overlays'
The output should include 'Unknown command: unknown-overlay'
The output should include 'Available commands'
The status should be failure
End
End
Expand Down
Loading