Always up-to-date Nix package for Claude Code - AI coding assistant in your terminal.
🚀 Automatically updated hourly to ensure you always have the latest Claude Code version.
While both this flake and upstream nixpkgs provide Claude Code as a Nix package, this flake focuses on:
- Immediate Updates: New Claude Code versions available within 1 hour of release
- Dedicated Maintenance: Focused repository for quick fixes when Claude Code changes
- Flake-First Design: Direct flake usage with Cachix binary cache
- Custom Wrapper Control: Ready to adapt when Claude Code adds new validations or requirements
- Native Binary: Self-contained binary with no runtime dependencies
While npm install -g @anthropic-ai/claude-code works, it has critical limitations:
- Disappears on Node.js Switch: When projects use different Node.js versions (via asdf/nvm), Claude Code becomes unavailable
- Must Reinstall Per Version: Need to install Claude Code separately for each Node.js version
- Not Declarative: Can't be managed in your Nix configuration
- Not Reproducible: Different Node.js versions can cause inconsistencies
- Outside Nix: Doesn't integrate with Nix's dependency management
Example Problem: You're working on a legacy project that uses Node.js 16 via asdf. When you switch to that project, your globally installed Claude Code (from Node.js 22) disappears from your PATH. Both this flake and upstream nixpkgs solve this by bundling Node.js with Claude Code.
While nixpkgs provides Claude Code, the update cycle can be slow:
- Pull requests can take days to weeks for review and merge
- Updates depend on maintainer availability
- You're tied to your nixpkgs channel's update schedule
- Emergency fixes for breaking changes can be delayed
This repository provides:
- Hourly Automated Updates: GitHub Actions checks for new versions every hour
- Instant Availability: Updates are automatically built and cached to Cachix
- Quick Fixes: When Claude Code breaks or adds new requirements, we can fix immediately
While Claude Code exists in nixpkgs, our approach offers specific advantages:
- Always Latest Version: Hourly automated checks vs waiting for nixpkgs PR reviews and merges
- Native Binary: Self-contained ~180MB binary with no runtime dependencies
- Flake with Binary Cache: Direct flake usage with Cachix means instant installation
- Dedicated Repository: Focused maintenance without the complexity of nixpkgs contribution process
| Feature | npm global | nixpkgs upstream | This Flake |
|---|---|---|---|
| Latest Version | ✅ Always | ❌ Delayed | ✅ Hourly checks |
| No Runtime Dependency | ❌ Requires Node.js | ❌ Bundles Node.js | ✅ Self-contained native binary |
| Survives Node Switch | ❌ Lost on switch | ✅ Always available | ✅ Always available |
| Binary Cache | ❌ None | ✅ NixOS cache | ✅ Cachix |
| Declarative Config | ❌ None | ✅ Yes | ✅ Yes |
| Exact Version Pinning | ✅ Nixpkgs revision | ✅ Exact tags (v2.1.71) or commit SHAs |
|
| Update Frequency | ✅ Immediate | ✅ < 1 hour | |
| Reproducible | ❌ No | ✅ Yes | ✅ Yes |
| Sandbox Builds | ❌ N/A | ✅ Yes | ✅ Yes |
- Always Up-to-Date: Automated hourly checks and updates via GitHub Actions
- Pre-built Binaries: Cachix provides instant installation without compilation
- Flake-native: Modern Nix flake for composable, reproducible deployments
- Home Manager Example: Sample configuration for permission persistence on macOS
- Custom Build Process: Optimized for Claude Code's specific requirements
# Run Claude Code directly without installing
nix run github:sadjow/claude-code-nix# Install to your profile (survives reboots)
nix profile install github:sadjow/claude-code-nixIf you're not using Home Manager or NixOS, here's the complete workflow for managing Claude Code with nix profile.
nix profile install github:sadjow/claude-code-nixwhich claude
claude --version# Update all flake-based packages
nix profile upgrade --all
# Or update only claude-code
nix profile upgrade '.*claude-code.*'# Revert to previous profile state
nix profile rollbacknix profile remove '.*claude-code.*'If claude command is not found after installation, ensure ~/.nix-profile/bin is in your PATH:
# Check if nix-profile/bin is in PATH
echo $PATH | tr ':' '\n' | grep nix-profile
# If not found, add to your shell config (~/.bashrc, ~/.zshrc, etc.)
export PATH="$HOME/.nix-profile/bin:$PATH"For multi-user Nix installations, the PATH is typically configured by /etc/profile.d/nix.sh or similar. Ensure your shell sources this file.
{
nixpkgs.overlays = [ claude-code.overlays.default ];
# pkgs.claude-code is now available
}You can override the binary name when building:
pkgs.claude-code.override { binName = "cc"; }To download pre-built binaries instead of compiling:
# Install cachix if you haven't already
nix-env -iA cachix -f https://cachix.org/api/v1/install
# Configure the claude-code cache
cachix use claude-codeUsing Cachix adds trust in this project's binary cache. If you prefer to verify builds locally from pinned source, skip Cachix and let Nix build locally instead.
Or add to your Nix configuration:
{
nix.settings = {
substituters = [ "https://claude-code.cachix.org" ];
trusted-public-keys = [ "claude-code.cachix.org-1:YeXf2aNu7UTX8Vwrze0za1WEDS+4DuI2kVeWEE4fsRk=" ];
};
}Add to your flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
claude-code.url = "github:sadjow/claude-code-nix";
};
outputs = { self, nixpkgs, claude-code, ... }: {
# Use as an overlay
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
modules = [
{
nixpkgs.overlays = [ claude-code.overlays.default ];
environment.systemPackages = [ pkgs.claude-code ];
}
];
};
};
}With Home Manager, add to your configuration:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
claude-code.url = "github:sadjow/claude-code-nix";
};
outputs = { self, nixpkgs, home-manager, claude-code, ... }: {
homeConfigurations."username" = home-manager.lib.homeManagerConfiguration {
modules = [
{
nixpkgs.overlays = [ claude-code.overlays.default ];
home.packages = [ pkgs.claude-code ];
}
];
};
};
}Choose between immutable pins and moving update channels using git refs.
Only exact version tags such as v2.1.71 or an exact commit SHA are true pins. v2, latest, and the bare github:sadjow/claude-code-nix reference are moving refs that intentionally follow newer commits over time.
| Ref | Example | Behavior | Security Posture |
|---|---|---|---|
| Exact version tag | v2.1.71 |
Immutable release tag | Best default for reproducible installs |
| Major tag | v2 |
Latest release in that major line | Moving channel, updates over time |
latest tag |
latest |
Newest release | Moving channel, updates over time |
| Default branch | github:sadjow/claude-code-nix |
Tracks repository main |
Moving channel, fastest updates |
# Always latest from the default branch
nix run github:sadjow/claude-code-nix
# Pin to an exact immutable release
nix run github:sadjow/claude-code-nix?ref=v2.1.71
# Track latest v2.x (auto-updates)
nix run github:sadjow/claude-code-nix?ref=v2
# Track latest v1.x
nix run github:sadjow/claude-code-nix?ref=v1{
inputs = {
# Always latest from the default branch
claude-code.url = "github:sadjow/claude-code-nix";
# Pin to an exact immutable release
claude-code.url = "github:sadjow/claude-code-nix?ref=v2.1.71";
# Track major version
claude-code.url = "github:sadjow/claude-code-nix?ref=v2";
};
}All versions from v1.0.35 onwards are tagged.
If you use this repository as a flake input, your own flake.lock records the resolved commit. Exact tags and commit SHAs give the strongest control; moving refs such as main, v2, and latest only change when you update your own lock file.
This repository is optimized for fast Claude Code updates. That makes the trust model worth stating explicitly.
package.nixfetches the native binaries with fixed hashes, so a build only succeeds if the downloaded artifacts match the expected content.flake.lockpins the flake inputs for a given repository revision.- The packaged binary disables Claude's built-in auto-updater, so updates happen through Nix rather than self-modification.
- CI builds and smoke-tests the package before update PRs land on
main.
- Trusting this repo means trusting the maintainer account and the GitHub Actions update workflow that creates and auto-merges version bump PRs.
- The upstream artifacts still come from Anthropic's npm package and native binary distribution.
- Using the
claude-codeCachix cache adds trust in this project's substituter key. Building locally avoids that extra trust layer. - Moving refs such as
main,v2, andlatesttrade stricter change control for convenience and freshness.
| Goal | Recommended Setup |
|---|---|
| Highest assurance | Pin an exact commit SHA, skip Cachix, and build locally |
| Balanced default | Pin an exact version tag and optionally use Cachix for faster installs |
| Fastest updates | Track the default branch, vX, or latest and accept the faster update cadence |
Forking is a valid option if you want to fully control update cadence, review upstream diffs yourself, or add additional policy checks before merging updates.
For most users, pinning an exact version tag is simpler and usually enough. A fork only meaningfully improves security if you also add your own review gate instead of automatically tracking upstream.
If you prefer a slower update cadence with broader community review, upstream nixpkgs may be a better fit than this flake.
- Downloads pre-built native binary from Anthropic's CDN
- Self-contained Bun single-file executable (~180MB)
- Uses
patchelfon Linux for NixOS compatibility - No external runtime dependencies
- Same binary as the official
claude.ai/install.shinstaller
The wrapper sets these environment variables:
| Variable | Purpose |
|---|---|
DISABLE_AUTOUPDATER=1 |
Prevents auto-updates (managed by Nix) |
DISABLE_INSTALLATION_CHECKS=1 |
Suppresses npm migration warning |
USE_BUILTIN_RIPGREP=0 |
Uses the Nix-provided ripgrep |
Earlier releases of this flake shipped three variants: claude-code (native), claude-code-node, and claude-code-bun. The Node.js and Bun variants ran Claude Code from the npm package's JavaScript entry point (cli.js).
Starting with Claude Code v2.1.113, Anthropic restructured the @anthropic-ai/claude-code npm package. cli.js was removed. The npm package is now a thin wrapper whose postinstall copies a platform-specific native binary (shipped via optionalDependencies) over a placeholder, and whose cli-wrapper.cjs fallback spawns that same binary through a short-lived Node.js process.
As a result, the JS variants here broke: they tried to exec node cli.js and hit MODULE_NOT_FOUND. Keeping them alive would have meant re-implementing Anthropic's postinstall in Nix only to execute the same native binary the native variant already ships. The variants were removed in favor of the single, self-contained claude-code package.
If you were using claude-code-node or claude-code-bun, switch to claude-code and claude; behavior is identical.
# Clone the repository
git clone https://github.com/sadjow/claude-code-nix
cd claude-code-nix
# Build the package
nix build
# Run tests
nix run . -- --version
# Check for version updates
./scripts/update-version.sh --check
# Enter development shell
nix developThis repository uses GitHub Actions to automatically check for new Claude Code versions every hour. When a new version is detected:
- A pull request is automatically created with the version update
- The tarball hash is automatically calculated
- Tests run on both Ubuntu and macOS to verify the build
- The PR auto-merges if all checks pass
- Version tags are automatically created (
vX.Y.Z,vX,latest)
The automated update workflow runs:
- Every hour (at the top of the hour)
- On manual trigger via GitHub Actions UI
This workflow is designed for freshness and build validation, not for manual review of every upstream release. New Claude Code versions are typically available in this flake within 30 minutes of being published to npm.
# Check for updates
./scripts/update-version.sh --check
# Update to latest version
./scripts/update-version.sh
# Update to specific version
./scripts/update-version.sh --version 1.0.82
# Show help
./scripts/update-version.sh --helpThe script automatically:
- Updates the version in
package.nix - Fetches native binary hashes for all platforms (darwin-arm64, darwin-x64, linux-x64, linux-arm64)
- Updates
flake.lockwith latest nixpkgs - Verifies the build succeeds
If you prefer to update manually:
- Edit
package.nixand change theversionfield - For each platform, fetch the native binary hash:
nix-prefetch-url https://downloads.claude.ai/claude-code-releases/VERSION/PLATFORM/claude - Update the matching entry in the
nativeHashesattribute set - Build and test locally:
nix build && ./result/bin/claude --version - Update
flake.lock:nix flake update - Submit a pull request
On macOS, Claude Code may ask for permissions after each Nix update because the binary path changes. To fix this:
- Create a stable symlink:
ln -s $(which claude) ~/.local/bin/claude - Add
~/.local/binto your PATH - Always run
claudefrom~/.local/bin/claude - Your
.claude.jsonand.claude/directory will be preserved
If you need to reset Claude's permissions:
rm -rf ~/.claude ~/.claude.jsonAnthropic provides an official native installer:
curl -fsSL https://claude.ai/install.sh | shThis downloads a self-contained binary bundled with Bun runtime.
| Aspect | Official Native Install | This Nix Flake |
|---|---|---|
| Simplicity | ✅ One command | Requires Nix |
| Same Binary | ✅ Yes | ✅ Yes |
| Latest Version | ✅ Hourly updates | |
| Version Pinning | ❌ No | ✅ Git tags |
| Rollback | ❌ Manual | ✅ nix profile rollback |
| Declarative | ❌ No | ✅ NixOS/Home Manager |
| Windows | Via WSL | Via WSL |
Choose official native install if: You want the simplest setup or don't use Nix.
Choose this flake if: You use NixOS/Home Manager, want declarative configuration, and are comfortable choosing between exact pins and faster-moving update channels.
The Nix packaging is MIT licensed. Claude Code itself is proprietary software by Anthropic.