# https://github.com/NixOS/nixpkgs/blob/4bf6c8d6f2d10c7924c08c7d51e02d6702484960/pkgs/by-name/cl/claude-code-bin/package.nix { lib, stdenvNoCC, fetchurl, installShellFiles, makeBinaryWrapper, autoPatchelfHook, procps, ripgrep, bubblewrap, socat, versionCheckHook, writableTmpDirAsHomeHook, }: let stdenv = stdenvNoCC; baseUrl = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases"; manifest = lib.importJSON ./manifest.json; platformKey = "${stdenv.hostPlatform.node.platform}-${stdenv.hostPlatform.node.arch}"; platformManifestEntry = manifest.platforms.${platformKey}; in stdenv.mkDerivation (finalAttrs: { pname = "claude-code"; inherit (manifest) version; src = fetchurl { url = "${baseUrl}/${finalAttrs.version}/${platformKey}/claude"; sha256 = platformManifestEntry.checksum; }; dontUnpack = true; dontBuild = true; __noChroot = stdenv.hostPlatform.isDarwin; # otherwise the bun runtime is executed instead of the binary dontStrip = true; nativeBuildInputs = [ installShellFiles makeBinaryWrapper ] ++ lib.optionals stdenv.hostPlatform.isElf [ autoPatchelfHook ]; strictDeps = true; installPhase = '' runHook preInstall installBin $src wrapProgram $out/bin/claude \ --set DISABLE_AUTOUPDATER 1 \ --set USE_BUILTIN_RIPGREP 0 \ --prefix PATH : ${ lib.makeBinPath ( [ # claude-code uses [node-tree-kill](https://github.com/pkrumins/node-tree-kill) which requires procps's pgrep(darwin) or ps(linux) procps # https://code.claude.com/docs/en/troubleshooting#search-and-discovery-issues ripgrep ] # the following packages are required for the sandbox to work (Linux only) ++ lib.optionals stdenv.hostPlatform.isLinux [ bubblewrap socat ] ) } runHook postInstall ''; doInstallCheck = true; nativeInstallCheckInputs = [ writableTmpDirAsHomeHook versionCheckHook ]; versionCheckKeepEnvironment = [ "HOME" ]; versionCheckProgramArg = "--version"; passthru.updateScript = ./update.sh; meta = { description = "Agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster"; homepage = "https://github.com/anthropics/claude-code"; downloadPage = "https://claude.com/product/claude-code"; changelog = "https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md"; license = lib.licenses.unfree; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; platforms = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]; maintainers = with lib.maintainers; [ xiaoxiangmoe mirkolenz ]; mainProgram = "claude"; }; })