diff --git a/home/home-darwin-work.nix b/home/home-darwin-work.nix index 525902e..84f5c80 100644 --- a/home/home-darwin-work.nix +++ b/home/home-darwin-work.nix @@ -14,6 +14,7 @@ in # System packages home.packages = with pkgs; [ autoraise + google-cloud-sdk ]; # Note: ghostty installed via Homebrew (managed outside of nix) @@ -222,6 +223,7 @@ in home.roles = { base.enable = true; + development.enable = true; }; imports = [ diff --git a/home/roles/development/default.nix b/home/roles/development/default.nix index 63ddab1..2efda01 100644 --- a/home/roles/development/default.nix +++ b/home/roles/development/default.nix @@ -22,12 +22,12 @@ in config = mkIf cfg.enable { home.packages = [ - pkgs.unstable.claude-code pkgs.unstable.claude-code-router pkgs.unstable.codex # Custom packages pkgs.custom.tea-rbw + pkgs.custom.claude-cli ]; # Install Claude Code humanlayer command and agent plugins diff --git a/packages/claude-cli/README.md b/packages/claude-cli/README.md new file mode 100644 index 0000000..8d63733 --- /dev/null +++ b/packages/claude-cli/README.md @@ -0,0 +1,92 @@ +# 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: + +```bash +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): + ```nix + version = "2.0.51"; # Update this + ``` + +2. All four platform sha256 hashes in the `srcs` attribute set (lines 11-27): + ```nix + 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: + +```bash +NIXPKGS_ALLOW_UNFREE=1 nix-build -E 'with import { config.allowUnfree = true; }; callPackage ./packages/claude-cli {}' +``` + +Verify the version: + +```bash +./result/bin/claude --version +``` + +Clean up the test build: + +```bash +rm result +``` + +### 4. Deploy + +Commit your changes and rebuild: + +```bash +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`: + +```bash +# 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. diff --git a/packages/claude-cli/default.nix b/packages/claude-cli/default.nix new file mode 100644 index 0000000..65883fc --- /dev/null +++ b/packages/claude-cli/default.nix @@ -0,0 +1,61 @@ +{ lib +, stdenv +, fetchurl +, autoPatchelfHook +, makeWrapper +}: + +let + version = "2.0.51"; + + srcs = { + aarch64-darwin = { + url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-arm64/claude"; + sha256 = "5c1a45b0e9793034df03e3a480fc9b388b554491d863d33e8c2d47312880580b"; + }; + x86_64-darwin = { + url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-x64/claude"; + sha256 = "b1bbd28a5ca33c1a411cb5376888485883ef913717e6e80179ac59ce8b6d0f9a"; + }; + x86_64-linux = { + url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-x64/claude"; + sha256 = "1e05cb6a6fd29b87c12a023231de65ed0b0ecdf43afb6fda88271f27949b72e4"; + }; + aarch64-linux = { + url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-arm64/claude"; + sha256 = "9752961c3bcb9f319eec9c308cdcce5bbbdd686288a2c952013768386107a574"; + }; + }; + + src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + +in stdenv.mkDerivation { + pname = "claude-cli"; + inherit version; + + src = fetchurl { + inherit (src) url sha256; + }; + + dontUnpack = true; + dontBuild = true; + + nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ]; + + installPhase = '' + runHook preInstall + + install -Dm755 $src $out/bin/claude + + runHook postInstall + ''; + + meta = with lib; { + description = "Terminal-based AI coding assistant from Anthropic"; + homepage = "https://www.anthropic.com/claude-code"; + license = licenses.unfree; + maintainers = [ ]; + platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ]; + mainProgram = "claude"; + }; +} diff --git a/packages/default.nix b/packages/default.nix index d6645e1..4a3a764 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -3,4 +3,5 @@ vulkanHDRLayer = pkgs.callPackage ./vulkan-hdr-layer {}; tea-rbw = pkgs.callPackage ./tea-rbw {}; app-launcher-server = pkgs.callPackage ./app-launcher-server {}; + claude-cli = pkgs.callPackage ./claude-cli {}; }