fix: update script for claude-code

This commit is contained in:
2025-11-27 22:09:48 +01:00
parent 1faec5b2d1
commit 41cb2ec791

View File

@@ -17,15 +17,16 @@ echo "Fetching source tarball..."
url="https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${version}.tgz" url="https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${version}.tgz"
hash=$(nix-prefetch-url --unpack --type sha256 "$url" 2>/dev/null) hash=$(nix-prefetch-url --unpack --type sha256 "$url" 2>/dev/null)
sri_hash=$(nix-hash --type sha256 --to-sri "$hash") sri_hash=$(nix-hash --type sha256 --to-sri "$hash")
sed -i "s|hash = \"sha256-.*\";|hash = \"$sri_hash\";|" default.nix # Update only the source hash (in fetchzip block)
sed -i "/src = pkgs.fetchzip/,/};/ s|hash = \"sha256-.*\";|hash = \"$sri_hash\";|" default.nix
# Generate new package-lock.json # Generate new package-lock.json
echo "Generating package-lock.json..." echo "Generating package-lock.json..."
npm i --package-lock-only @anthropic-ai/claude-code@"$version" npm i --package-lock-only @anthropic-ai/claude-code@"$version"
rm -f package.json rm -f package.json
# Set placeholder for npmDepsHash # Set placeholder for npmDepsHash only (in fetchNpmDeps block)
sed -i "s|hash = \"sha256-.*\";|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|g" default.nix sed -i "/npmDeps = pkgs.fetchNpmDeps/,/};/ s|hash = \"sha256-.*\";|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|" default.nix
echo "" echo ""
echo "Updated to version $version" echo "Updated to version $version"
@@ -38,7 +39,7 @@ cd "$repo_root"
# Build to get the correct npmDepsHash # Build to get the correct npmDepsHash
echo "Building package to determine 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) build_output=$(NIXPKGS_ALLOW_UNFREE=1 nix build --impure --no-link --expr 'with import <nixpkgs> {}; callPackage ./utils/pkgs/claude-code { inherit lib pkgs runCommand claude-code; }' 2>&1 || true)
# Extract the hash from build output # 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}') npm_deps_hash=$(echo "$build_output" | grep -oP "got:\s+sha256-[A-Za-z0-9+/=]+" | tail -1 | awk '{print $2}')
@@ -54,13 +55,13 @@ echo "npmDepsHash: $npm_deps_hash"
# Update npmDepsHash in default.nix # Update npmDepsHash in default.nix
cd "$repo_root/utils/pkgs/claude-code" cd "$repo_root/utils/pkgs/claude-code"
sed -i "s|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|hash = \"$npm_deps_hash\";|" default.nix sed -i "/npmDeps = pkgs.fetchNpmDeps/,/};/ s|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|hash = \"$npm_deps_hash\";|" default.nix
# Verify the build works # Verify the build works
echo "" echo ""
echo "Verifying build..." echo "Verifying build..."
cd "$repo_root" 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 if NIXPKGS_ALLOW_UNFREE=1 nix build --impure --no-link --expr 'with import <nixpkgs> {}; callPackage ./utils/pkgs/claude-code { inherit lib pkgs runCommand claude-code; }'; then
echo "" echo ""
echo "✓ Successfully updated claude-code to version $version" echo "✓ Successfully updated claude-code to version $version"
echo " Source hash: $sri_hash" echo " Source hash: $sri_hash"