{ lib , stdenv , fetchurl , autoPatchelfHook }: let version = "2.0.53"; srcs = { aarch64-darwin = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-arm64/claude"; sha256 = "28c3ad73a20f3ae7ab23efa24d45a9791ccbe071284f1622d4e5e2b89c4a15b7"; }; x86_64-darwin = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-x64/claude"; sha256 = "a27f7b75a51514658640432a0afec8be130673eb7dbecc9a4d742527dd85d29a"; }; x86_64-linux = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-x64/claude"; sha256 = "9c4cc19e207fb6bf7ea140a1580d5ed0dd0a481af471f23614d5a140a4abf1c6"; }; aarch64-linux = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-arm64/claude"; sha256 = "a5d4044034f3b63c38379bc2dd4067a4dd3c8ec48965ba8e66e3623774a93b72"; }; }; src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); in stdenv.mkDerivation { pname = "claude-code"; 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"; }; }