Files
nixos-configs/packages/claude-code
mayor 53e3bbe78f
All checks were successful
CI / check (push) Successful in 3m32s
fix(claude-code): preserve bun appended bundle during NixOS build
Bun standalone executables store their JavaScript code by appending it
after the ELF sections, marked with "---- Bun! ----". The standard Nix
build process was corrupting this:

- autoPatchelfHook rewrites the entire ELF, losing appended data
- strip removes data after ELF sections
- patchelf shrink-rpath also rewrites the ELF

Fix by:
- Using dontStrip and dontPatchELF to skip automatic fixup
- Manually running patchelf --set-interpreter which modifies in-place
  without rewriting the entire file structure

This restores the binary from 99MB (bare bun runtime) to 220MB (full
claude-code application).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Executed-By: mayor
Role: mayor
2026-01-19 10:39:58 -08:00
..

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

Run the update script to automatically fetch and update to the latest version:

cd packages/claude-cli
./update.sh

The script will:

  • Fetch the latest version from Homebrew cask
  • Update version and all SHA256 hashes in default.nix
  • Show you what changed

For a dry-run to see what would change:

./update.sh --dry-run

After the script completes, follow the "Test the Build" steps below.

Manual Update

If you prefer to update manually, or if the automated script fails:

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 version number
  • SHA256 hashes for all platforms (arm64, x86_64, x86_64_linux, arm64_linux)

2. Update default.nix

Edit default.nix and update:

  1. The version variable (line 9):

    version = "2.0.51";  # Update this
    
  2. All four platform sha256 hashes in the srcs attribute 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.