feat: update claude-code
This commit is contained in:
parent
4045aa1859
commit
6bfaf7d2ec
3 changed files with 105 additions and 39 deletions
|
|
@ -1,57 +1,68 @@
|
|||
# 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"] ["claude-code-bin"] ["vscode-extensions" "anthropic" "claude-code"]])'
|
||||
# nix-shell maintainers/scripts/update.nix --argstr commit true --arg predicate '(path: pkg: builtins.elem path [["claude-code"] ["vscode-extensions" "anthropic" "claude-code"]])'
|
||||
# ```
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
buildNpmPackage,
|
||||
fetchzip,
|
||||
stdenvNoCC,
|
||||
fetchurl,
|
||||
installShellFiles,
|
||||
makeBinaryWrapper,
|
||||
autoPatchelfHook,
|
||||
procps,
|
||||
ripgrep,
|
||||
bubblewrap,
|
||||
socat,
|
||||
versionCheckHook,
|
||||
writableTmpDirAsHomeHook,
|
||||
bubblewrap,
|
||||
procps,
|
||||
socat,
|
||||
}:
|
||||
buildNpmPackage (finalAttrs: {
|
||||
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";
|
||||
version = "2.1.112";
|
||||
inherit (manifest) version;
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${finalAttrs.version}.tgz";
|
||||
hash = "sha256-SJJqU7XHbu9IRGPMJNUg6oaMZiQUKqJhI2wm7BnR1gs=";
|
||||
src = fetchurl {
|
||||
url = "${baseUrl}/${finalAttrs.version}/${platformKey}/claude";
|
||||
sha256 = platformManifestEntry.checksum;
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-bdkej9Z41GLew9wi1zdNX+Asauki3nT1+SHmBmaUIBU=";
|
||||
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;
|
||||
|
||||
postPatch = ''
|
||||
cp ${./package-lock.json} package-lock.json
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# https://github.com/anthropics/claude-code/issues/15195
|
||||
substituteInPlace cli.js \
|
||||
--replace-fail '#!/bin/sh' '#!/usr/bin/env sh'
|
||||
'';
|
||||
installBin $src
|
||||
|
||||
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 \
|
||||
--set-default FORCE_AUTOUPDATE_PLUGINS 1 \
|
||||
--set DISABLE_INSTALLATION_CHECKS 1 \
|
||||
--unset DEV \
|
||||
--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 [
|
||||
|
|
@ -60,6 +71,8 @@ buildNpmPackage (finalAttrs: {
|
|||
]
|
||||
)
|
||||
}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
|
|
@ -68,23 +81,32 @@ buildNpmPackage (finalAttrs: {
|
|||
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://www.npmjs.com/package/@anthropic-ai/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; [
|
||||
adeci
|
||||
malo
|
||||
markus1189
|
||||
mirkolenz
|
||||
omarjatoi
|
||||
oskarwires
|
||||
xiaoxiangmoe
|
||||
];
|
||||
mainProgram = "claude";
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
|
||||
};
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue