{ 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"; }; }