feat: add updated claude code
This commit is contained in:
72
utils/pkgs/claude-code/update.sh
Executable file
72
utils/pkgs/claude-code/update.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p nodejs nix-prefetch cacert
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
# Get latest version from npm
|
||||
version=$(npm view @anthropic-ai/claude-code version)
|
||||
echo "Latest version: $version"
|
||||
|
||||
# Update version in default.nix
|
||||
sed -i "s/version = \".*\";/version = \"$version\";/" default.nix
|
||||
|
||||
# Fetch and update source hash
|
||||
echo "Fetching source tarball..."
|
||||
url="https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${version}.tgz"
|
||||
hash=$(nix-prefetch-url --unpack --type sha256 "$url" 2>/dev/null)
|
||||
sri_hash=$(nix-hash --type sha256 --to-sri "$hash")
|
||||
sed -i "s|hash = \"sha256-.*\";|hash = \"$sri_hash\";|" default.nix
|
||||
|
||||
# Generate new package-lock.json
|
||||
echo "Generating package-lock.json..."
|
||||
npm i --package-lock-only @anthropic-ai/claude-code@"$version"
|
||||
rm -f package.json
|
||||
|
||||
# Set placeholder for npmDepsHash
|
||||
sed -i "s|hash = \"sha256-.*\";|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|g" default.nix
|
||||
|
||||
echo ""
|
||||
echo "Updated to version $version"
|
||||
echo "Source hash: $sri_hash"
|
||||
echo ""
|
||||
|
||||
# Go to repo root (3 levels up from utils/pkgs/claude-code)
|
||||
repo_root="$(cd ../../.. && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
# Build to get the correct npmDepsHash
|
||||
echo "Building package to determine npmDepsHash..."
|
||||
build_output=$(NIXPKGS_ALLOW_UNFREE=1 nix build --impure --no-link --expr 'with import <nixpkgs> {}; callPackage ./utils/pkgs/claude-code { inherit lib pkgs runCommand; }' 2>&1 || true)
|
||||
|
||||
# Extract the hash from build output
|
||||
npm_deps_hash=$(echo "$build_output" | grep -oP "got:\s+sha256-[A-Za-z0-9+/=]+" | tail -1 | awk '{print $2}')
|
||||
|
||||
if [ -z "$npm_deps_hash" ]; then
|
||||
echo "Error: Could not determine npmDepsHash from build output"
|
||||
echo "Build output:"
|
||||
echo "$build_output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "npmDepsHash: $npm_deps_hash"
|
||||
|
||||
# Update npmDepsHash in default.nix
|
||||
cd "$repo_root/utils/pkgs/claude-code"
|
||||
sed -i "s|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|hash = \"$npm_deps_hash\";|" default.nix
|
||||
|
||||
# Verify the build works
|
||||
echo ""
|
||||
echo "Verifying build..."
|
||||
cd "$repo_root"
|
||||
if NIXPKGS_ALLOW_UNFREE=1 nix build --impure --no-link --expr 'with import <nixpkgs> {}; callPackage ./utils/pkgs/claude-code { inherit lib pkgs runCommand; }'; then
|
||||
echo ""
|
||||
echo "✓ Successfully updated claude-code to version $version"
|
||||
echo " Source hash: $sri_hash"
|
||||
echo " npmDepsHash: $npm_deps_hash"
|
||||
else
|
||||
echo ""
|
||||
echo "✗ Build failed after updating hashes"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user