{ lib , stdenv , fetchurl , autoPatchelfHook }: let version = "2.1.12"; srcs = { aarch64-darwin = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-arm64/claude"; sha256 = "40be59519a84bd35eb1111aa46f72aa6b3443866d3f6336252a198fdcaefbbe5"; }; x86_64-darwin = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-x64/claude"; sha256 = "0eee4b46c91749480bf856f88e49b15a3e944faa9d346679c5f0c0d7fa6f2f54"; }; x86_64-linux = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-x64/claude"; sha256 = "3fe979215489dc1b31463fadf95ed2d2d5473a9969447bb7a46431f4578847d4"; }; aarch64-linux = { url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-arm64/claude"; sha256 = "e214b1d3b5afd4cd2de9177359001d41a3eb98cb1e3665fe97edc592f5aa132f"; }; }; 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"; }; }