aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkgs/claude-code/default.nix28
-rw-r--r--pkgs/claude-code/package-lock.json12
-rwxr-xr-xpkgs/claude-code/update.sh13
3 files changed, 25 insertions, 28 deletions
diff --git a/pkgs/claude-code/default.nix b/pkgs/claude-code/default.nix
index ef55886..7cee1dd 100644
--- a/pkgs/claude-code/default.nix
+++ b/pkgs/claude-code/default.nix
@@ -1,24 +1,22 @@
-# https://github.com/NixOS/nixpkgs/blob/6027c30c8e9810896b92429f0092f624f7b1aace/pkgs/by-name/cl/claude-code/package.nix
+# https://github.com/NixOS/nixpkgs/blob/7df7ff7d8e00218376575f0acdcc5d66741351ee/pkgs/by-name/cl/claude-code/package.nix
{
lib,
buildNpmPackage,
fetchzip,
- nodejs_20,
+ writableTmpDirAsHomeHook,
+ versionCheckHook,
}:
-
-buildNpmPackage rec {
+buildNpmPackage (finalAttrs: {
pname = "claude-code";
version = "2.0.1";
- nodejs = nodejs_20; # required for sandboxed Nix builds on Darwin
-
src = fetchzip {
- url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${version}.tgz";
+ url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${finalAttrs.version}.tgz";
hash = "sha256-LUbDPFa0lY74MBU4hvmYVntt6hVZy6UUZFN0iB4Eno8=";
};
- npmDepsHash = "sha256-mxMEO1r5KzHw7d3NRJSWtkc9vnnd5XbgD2D5MYP1zO0=";
+ npmDepsHash = "sha256-DehkeMZvzn+hvcCDzJfd4p9oYc1GSZm8gu8vKS4Uncw=";
postPatch = ''
cp ${./package-lock.json} package-lock.json
@@ -26,7 +24,7 @@ buildNpmPackage rec {
dontNpmBuild = true;
- AUTHORIZED = "1";
+ 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
@@ -37,6 +35,14 @@ buildNpmPackage rec {
--unset DEV
'';
+ doInstallCheck = true;
+ nativeInstallCheckInputs = [
+ writableTmpDirAsHomeHook
+ versionCheckHook
+ ];
+ versionCheckKeepEnvironment = [ "HOME" ];
+ versionCheckProgramArg = "--version";
+
passthru.updateScript = ./update.sh;
meta = {
@@ -46,8 +52,10 @@ buildNpmPackage rec {
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [
malo
+ markus1189
omarjatoi
+ xiaoxiangmoe
];
mainProgram = "claude";
};
-}
+})
diff --git a/pkgs/claude-code/package-lock.json b/pkgs/claude-code/package-lock.json
index 1605898..4c777b7 100644
--- a/pkgs/claude-code/package-lock.json
+++ b/pkgs/claude-code/package-lock.json
@@ -1,18 +1,12 @@
{
- "name": "claude-code",
- "version": "1.0.17",
+ "name": "@anthropic-ai/claude-code",
+ "version": "2.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
- "dependencies": {
- "@anthropic-ai/claude-code": "^2.0.1"
- }
- },
- "node_modules/@anthropic-ai/claude-code": {
+ "name": "@anthropic-ai/claude-code",
"version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-2.0.1.tgz",
- "integrity": "sha512-2SboYcdJ+dsE2K784dbJ4ohVWlAkLZhU7mZG1lebyG6TvGLXLhjc2qTEfCxSeelCjJHhIh/YkNpe06veB4IgBw==",
"license": "SEE LICENSE IN README.md",
"bin": {
"claude": "cli.js"
diff --git a/pkgs/claude-code/update.sh b/pkgs/claude-code/update.sh
index ede1f43..4d0d1f9 100755
--- a/pkgs/claude-code/update.sh
+++ b/pkgs/claude-code/update.sh
@@ -1,17 +1,12 @@
#!/usr/bin/env nix-shell
-#!nix-shell -i bash -p nodePackages.npm nix-update
+#!nix-shell --pure -i bash --packages nodejs nix-update git
-# https://github.com/NixOS/nixpkgs/blob/3016b4b15d13f3089db8a41ef937b13a9e33a8df/pkgs/by-name/cl/claude-code/update.sh
+# https://github.com/NixOS/nixpkgs/blob/7df7ff7d8e00218376575f0acdcc5d66741351ee/pkgs/by-name/cl/claude-code/update.sh
set -euo pipefail
version=$(npm view @anthropic-ai/claude-code version)
-# Generate updated lock file
-cd "$(dirname "${BASH_SOURCE[0]}")"
-npm i --package-lock-only @anthropic-ai/claude-code@"$version"
-rm -f package.json
-
# Update version and hashes
-cd -
-nix-update claude-code --version "$version"
+AUTHORIZED=1 NIXPKGS_ALLOW_UNFREE=1 nix-update claude-code --version="$version" --generate-lockfile
+# nix-update vscode-extensions.anthropic.claude-code --use-update-script --version "$version"