fix: update script for claude-code
This commit is contained in:
@@ -17,15 +17,16 @@ 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
|
||||
# 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
|
||||
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
|
||||
# Set placeholder for npmDepsHash only (in fetchNpmDeps block)
|
||||
sed -i "/npmDeps = pkgs.fetchNpmDeps/,/};/ s|hash = \"sha256-.*\";|hash = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\";|" default.nix
|
||||
|
||||
echo ""
|
||||
echo "Updated to version $version"
|
||||
@@ -38,7 +39,7 @@ 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)
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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 "✓ Successfully updated claude-code to version $version"
|
||||
echo " Source hash: $sri_hash"
|
||||
|
||||
Reference in New Issue
Block a user