76 lines
2.7 KiB
Nix
76 lines
2.7 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchurl
|
|
, patchelf
|
|
, glibc
|
|
}:
|
|
|
|
let
|
|
version = "2.1.69";
|
|
|
|
srcs = {
|
|
aarch64-darwin = {
|
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-arm64/claude";
|
|
sha256 = "a86e14f44b167c1e8dbf764f76755b92ecf52c097d732a3461fe65b5fb60be05";
|
|
};
|
|
x86_64-darwin = {
|
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/darwin-x64/claude";
|
|
sha256 = "e5987b4dd502a6542bf86c3c0bcd1d533b774616fc7d49566ce0b2040e6c1374";
|
|
};
|
|
x86_64-linux = {
|
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-x64/claude";
|
|
sha256 = "b3bdbd5a3cbf8caafe353022170df77fefa80b00003074d4d27e7da8c59e629a";
|
|
};
|
|
aarch64-linux = {
|
|
url = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/${version}/linux-arm64/claude";
|
|
sha256 = "ecc7bbf10513ff122327866eb97212945b73afd7f81e30700375cdf10f50b2a3";
|
|
};
|
|
};
|
|
|
|
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
|
|
|
in stdenv.mkDerivation {
|
|
pname = "claude-code";
|
|
inherit version;
|
|
|
|
src = fetchurl {
|
|
inherit (src) url sha256;
|
|
};
|
|
|
|
dontUnpack = true;
|
|
dontBuild = true;
|
|
# Bun standalone binaries have JS code appended after the ELF sections
|
|
# stripping/patching would remove or corrupt this appended data
|
|
dontStrip = true;
|
|
dontPatchELF = true;
|
|
|
|
# Don't use autoPatchelfHook - it rewrites the ELF and strips the appended
|
|
# bun bundle (the JS code is appended after the ELF sections)
|
|
nativeBuildInputs = lib.optionals stdenv.isLinux [ patchelf ];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
install -Dm755 $src $out/bin/claude
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
# Manually patch the interpreter for bun standalone binaries
|
|
# patchelf --set-interpreter modifies in-place without rewriting the entire ELF,
|
|
# preserving the appended JS bundle that bun needs at runtime
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
|
interpreter="${glibc}/lib/${if stdenv.hostPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else "ld-linux-x86-64.so.2"}"
|
|
patchelf --set-interpreter "$interpreter" $out/bin/claude
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Terminal-based AI coding assistant from Anthropic";
|
|
homepage = "https://www.anthropic.com/claude-code";
|
|
license = licenses.unfree;
|
|
maintainers = [ ];
|
|
platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
|
|
mainProgram = "claude";
|
|
};
|
|
}
|