# https://github.com/NixOS/nixpkgs/blob/ffbc9f8cbaacfb331b6017d5a5abb21a492c9a38/pkgs/by-name/cl/claude-code/package.nix # NOTE: Use the following command to update the package # ```sh # nix-shell maintainers/scripts/update.nix --argstr commit true --arg predicate '(path: pkg: builtins.elem path [["claude-code"] ["vscode-extensions" "anthropic" "claude-code"]])' # ``` { lib, buildNpmPackage, fetchzip, writableTmpDirAsHomeHook, versionCheckHook, }: buildNpmPackage (finalAttrs: { pname = "claude-code"; version = "2.1.9"; src = fetchzip { url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${finalAttrs.version}.tgz"; hash = "sha256-TU+54QVtcFaUErv8YB0NxmgP+0eUqa2JEjAVRHKPICs="; }; npmDepsHash = "sha256-yZ5hFIqdKh6VYPGtdIaUq7CW9mnCyeFflr02laU8K0A="; postPatch = '' cp ${./package-lock.json} package-lock.json ''; dontNpmBuild = true; env.AUTHORIZED = "1"; # `claude-code` tries to auto-update by default, this disables that functionality. # https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview#environment-variables # The DEV=true env var causes claude to crash with `TypeError: window.WebSocket is not a constructor` postInstall = '' wrapProgram $out/bin/claude \ --set DISABLE_AUTOUPDATER 1 \ --unset DEV ''; doInstallCheck = true; nativeInstallCheckInputs = [ writableTmpDirAsHomeHook versionCheckHook ]; versionCheckKeepEnvironment = [ "HOME" ]; 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://www.npmjs.com/package/@anthropic-ai/claude-code"; license = lib.licenses.unfree; maintainers = with lib.maintainers; [ adeci malo markus1189 omarjatoi xiaoxiangmoe ]; mainProgram = "claude"; }; })