Created
March 16, 2025 04:54
-
-
Save MatrixManAtYrService/47c83952acece37598778c67c29711e3 to your computer and use it in GitHub Desktop.
claude code in a nix devshell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, claude-code-tarball, claude-code-version }: | |
pkgs.stdenv.mkDerivation { | |
name = "claude-code"; | |
version = claude-code-version; | |
src = claude-code-tarball; | |
dontConfigure = true; | |
dontBuild = true; | |
installPhase = '' | |
mkdir -p $out/bin | |
mkdir -p $out/lib/node_modules/@anthropic-ai/claude-code | |
ls ${claude-code-tarball} | |
cp -r ${claude-code-tarball}/* $out/lib/node_modules/@anthropic-ai/claude-code/ | |
cat > $out/bin/claude-code << EOF | |
#!/bin/sh | |
exec ${pkgs.nodejs}/bin/node $out/lib/node_modules/@anthropic-ai/claude-code/cli.js "\$@" | |
EOF | |
# Make the wrapper script executable | |
chmod +x $out/bin/claude-code | |
# Make the ripgrep binaries executable for all platforms | |
chmod +x $out/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/*/rg* | |
''; | |
buildInputs = [ pkgs.nodejs ]; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
inputs = { | |
flake-utils.url = "github:numtide/flake-utils"; | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
claude-code-tarball = { | |
url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-0.2.45.tgz"; | |
flake = false; | |
}; | |
}; | |
outputs = { self, nixpkgs, flake-utils, claude-code-tarball }: | |
flake-utils.lib.eachDefaultSystem (system: | |
let | |
pkgs = import nixpkgs { | |
inherit system; | |
}; | |
claude-code = import ./claude.nix { | |
inherit pkgs claude-code-tarball; | |
claude-code-version = "0.2.45"; | |
}; | |
in | |
{ | |
devShells.default = pkgs.mkShell { | |
packages = [ | |
claude-code | |
]; | |
}; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There might be some AI generated idiocy in here, I haven't scrutinized it much, but it does work.