feat(nix): update claude-code package and dependencies

- Upgraded `claude-code` to version 2.1.34 and updated associated npm dependencies and hash values.
- Refactored `update.sh` to use `nix shell` instead of `nix-shell` for improved compatibility.
- Added musl-based `sharp` dependencies and adjusted sandbox requirements in `package.nix`.
This commit is contained in:
Harald Hoyer 2026-02-06 08:57:49 +01:00
parent 9b42e808d3
commit 4bc62866a8
4 changed files with 124 additions and 13 deletions

View file

@ -1,23 +1,37 @@
# 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"]])'
# ```
{
lib,
stdenv,
buildNpmPackage,
fetchzip,
writableTmpDirAsHomeHook,
versionCheckHook,
writableTmpDirAsHomeHook,
bubblewrap,
procps,
socat,
}:
buildNpmPackage (finalAttrs: {
pname = "claude-code";
version = "2.0.51";
version = "2.1.34";
src = fetchzip {
url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${finalAttrs.version}.tgz";
hash = "sha256-rfJZaACY+Kbm+0lWOPwAfl/x2yFxskLKZpJJhqlccSY=";
hash = "sha256-J3kltFY5nR3PsRWbW310VqD/6hhfMbVSvynv0eaIi3M=";
};
npmDepsHash = "sha256-/5Qh99vAcTiFz6FrzJgm26RserqxVjLYqOOx5q5hkgc=";
npmDepsHash = "sha256-n762einDxLUUXWMsfdPVhA/kn0ywlJgFQ2ZGoEk3E68=";
strictDeps = true;
postPatch = ''
cp ${./package-lock.json} package-lock.json
# https://github.com/anthropics/claude-code/issues/15195
substituteInPlace cli.js \
--replace-fail '#!/bin/sh' '#!/usr/bin/env sh'
'';
dontNpmBuild = true;
@ -30,7 +44,21 @@ buildNpmPackage (finalAttrs: {
postInstall = ''
wrapProgram $out/bin/claude \
--set DISABLE_AUTOUPDATER 1 \
--unset DEV
--set DISABLE_INSTALLATION_CHECKS 1 \
--unset DEV \
--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
]
# the following packages are required for the sandbox to work (Linux only)
++ lib.optionals stdenv.hostPlatform.isLinux [
bubblewrap
socat
]
)
}
'';
doInstallCheck = true;
@ -39,7 +67,6 @@ buildNpmPackage (finalAttrs: {
versionCheckHook
];
versionCheckKeepEnvironment = [ "HOME" ];
versionCheckProgramArg = "--version";
passthru.updateScript = ./update.sh;
@ -49,6 +76,7 @@ buildNpmPackage (finalAttrs: {
downloadPage = "https://www.npmjs.com/package/@anthropic-ai/claude-code";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [
adeci
malo
markus1189
omarjatoi