# Claude Code at the exact version Claude Desktop is built against: the app's # Code tab runs it. Unpatched, the app downloads this same file at run time # into ~/.config/Claude/claude-code, where NixOS can't run it; default.nix # points the app here instead. # # To update (after changing the app's version): the app's pin is in its # app.asar, in the JSON with "baseUrl":"https://downloads.claude.ai/claude-code-releases". # Take "version" and platforms."linux-x64".checksum from it: # asar extract .../resources/app.asar /tmp/app # grep -o '{"version":"[0-9.]*","manifest".\{0,1500\}' /tmp/app/.vite/build/*.js # The app's build fails with a message if the two versions disagree. { lib, stdenv, fetchurl, zstd, autoPatchelfHook, }: stdenv.mkDerivation (finalAttrs: { pname = "claude-code-for-desktop"; version = "2.1.299"; src = fetchurl { url = "https://downloads.claude.ai/claude-code-releases/${finalAttrs.version}/linux-x64/claude.zst"; sha256 = "20ca25213130255bacdcae3ed5df3fc99e1d8e86cdf46e9188b7ff9c1b478fa4"; }; nativeBuildInputs = [ zstd autoPatchelfHook ]; dontUnpack = true; # The program's JavaScript is appended to the executable; strip would cut it. dontStrip = true; installPhase = '' runHook preInstall install -d $out/bin zstd -d $src -o $out/bin/claude chmod 755 $out/bin/claude runHook postInstall ''; doInstallCheck = true; installCheckPhase = '' HOME=$TMPDIR $out/bin/claude --version | grep -F ${finalAttrs.version} ''; meta = { description = "Claude Code, the version Claude Desktop's Code tab runs"; homepage = "https://claude.com/claude-code"; license = lib.licenses.unfree; mainProgram = "claude"; platforms = [ "x86_64-linux" ]; sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; }; })