aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkgs/claude-code/default.nix
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-01-29 19:14:38 +0900
committernsfisis <nsfisis@gmail.com>2026-01-29 19:14:38 +0900
commitf981cd0f054309d5a238df8f2e452f6c78b2e920 (patch)
tree68b34dd9ef4d8ca370b5e76c6a07429eacb27d40 /pkgs/claude-code/default.nix
parentd8a737f52082151bc180917f84bd6f029f0ec71a (diff)
downloadnur-packages-f981cd0f054309d5a238df8f2e452f6c78b2e920.tar.gz
nur-packages-f981cd0f054309d5a238df8f2e452f6c78b2e920.tar.zst
nur-packages-f981cd0f054309d5a238df8f2e452f6c78b2e920.zip
feat(claude-code): upgrade to 2.1.23
Diffstat (limited to 'pkgs/claude-code/default.nix')
-rw-r--r--pkgs/claude-code/default.nix98
1 files changed, 68 insertions, 30 deletions
diff --git a/pkgs/claude-code/default.nix b/pkgs/claude-code/default.nix
index 9d514bd..a84e696 100644
--- a/pkgs/claude-code/default.nix
+++ b/pkgs/claude-code/default.nix
@@ -1,42 +1,74 @@
-# https://github.com/NixOS/nixpkgs/blob/ffbc9f8cbaacfb331b6017d5a5abb21a492c9a38/pkgs/by-name/cl/claude-code/package.nix
+# https://github.com/NixOS/nixpkgs/blob/4bf6c8d6f2d10c7924c08c7d51e02d6702484960/pkgs/by-name/cl/claude-code-bin/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,
+ stdenvNoCC,
+ fetchurl,
+ installShellFiles,
+ makeBinaryWrapper,
+ autoPatchelfHook,
+ procps,
+ ripgrep,
+ bubblewrap,
+ socat,
versionCheckHook,
+ writableTmpDirAsHomeHook,
}:
-buildNpmPackage (finalAttrs: {
- pname = "claude-code";
- version = "2.1.22";
+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-bin";
+ inherit (manifest) version;
- src = fetchzip {
- url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${finalAttrs.version}.tgz";
- hash = "sha256-vy7osk3UAOEgsJx9jdcGe2wICOk5Urzxh1WLAHyHM+U=";
+ src = fetchurl {
+ url = "${baseUrl}/${finalAttrs.version}/${platformKey}/claude";
+ sha256 = platformManifestEntry.checksum;
};
- npmDepsHash = "sha256-W3q8N01oPRDd6HuMBjvGD9zPvJZjr0KnfoSQEoADq4U=";
+ dontUnpack = true;
+ dontBuild = true;
+ __noChroot = stdenv.hostPlatform.isDarwin;
+ # otherwise the bun runtime is executed instead of the binary
+ dontStrip = true;
- postPatch = ''
- cp ${./package-lock.json} package-lock.json
- '';
+ nativeBuildInputs = [
+ installShellFiles
+ makeBinaryWrapper
+ ]
+ ++ lib.optionals stdenv.hostPlatform.isElf [ autoPatchelfHook ];
- dontNpmBuild = true;
+ strictDeps = true;
- env.AUTHORIZED = "1";
+ installPhase = ''
+ runHook preInstall
+
+ installBin $src
- # `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
+ --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;
@@ -45,20 +77,26 @@ 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
- omarjatoi
xiaoxiangmoe
+ mirkolenz
];
mainProgram = "claude";
};