Create custom Nix package for Claude Code CLI that fetches directly from Anthropic's Google Cloud Storage distribution instead of npm registry, working around Block's Cloudflare Teams dependency confusion protection. - Add claude-cli package with platform-specific binaries - Include comprehensive README with update instructions - Enable development role on work machine - Switch from unstable.claude-code to custom.claude-cli - Add google-cloud-sdk to work machine packages
2.4 KiB
claude-cli
Custom Nix package for Claude Code CLI.
Why This Package Exists
The official claude-code package in nixpkgs tries to fetch from npm registry, which is blocked by Block's corporate security (Cloudflare Teams dependency confusion protection). This custom package fetches directly from Anthropic's Google Cloud Storage distribution, bypassing the npm registry entirely.
Updating to a New Version
When a new version of Claude Code is released, follow these steps:
1. Find the Latest Version and Hashes
Check the Homebrew cask formula for the latest version info:
curl -s "https://raw.githubusercontent.com/Homebrew/homebrew-cask/HEAD/Casks/c/claude-code.rb" | head -50
This will show:
- The latest
versionnumber - SHA256 hashes for all platforms (
arm64,x86_64,x86_64_linux,arm64_linux)
2. Update default.nix
Edit default.nix and update:
-
The
versionvariable (line 9):version = "2.0.51"; # Update this -
All four platform sha256 hashes in the
srcsattribute set (lines 11-27):aarch64-darwin = { sha256 = "..."; # Update from Homebrew cask "arm:" value }; x86_64-darwin = { sha256 = "..."; # Update from Homebrew cask "x86_64:" value }; x86_64-linux = { sha256 = "..."; # Update from Homebrew cask "x86_64_linux:" value }; aarch64-linux = { sha256 = "..."; # Update from Homebrew cask "arm64_linux:" value };
3. Test the Build
Before committing, test that the package builds successfully:
NIXPKGS_ALLOW_UNFREE=1 nix-build -E 'with import <nixpkgs> { config.allowUnfree = true; }; callPackage ./packages/claude-cli {}'
Verify the version:
./result/bin/claude --version
Clean up the test build:
rm result
4. Deploy
Commit your changes and rebuild:
git add packages/claude-cli/
git commit -m "claude-cli: Update to version X.Y.Z"
darwin-rebuild switch --flake .#blkfv4yf49kt7
Alternative: Automated Hash Fetching
If you prefer to fetch hashes automatically, you can use nix-prefetch-url:
# For macOS ARM64 (your current platform)
nix-prefetch-url "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/VERSION/darwin-arm64/claude"
# For other platforms, replace VERSION and adjust the platform string:
# darwin-x64, linux-x64, linux-arm64
This will download the file and output the SHA256 hash.