Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Nix Installer (User-Local)

This Nix configuration provides a user-local installation of claude-code that doesn't require root permissions and won't interfere with auto-update capabilities.

Features

  • User-local installation: Installs to ~/.local/share/claude-code/npm instead of system directories
  • No sudo required: Uses npm prefix configuration to avoid permission issues
  • Auto-update friendly: Includes a claude-update command for easy updates
  • Preserves npm behavior: Similar to using .npmrc with custom prefix
  • Includes dependencies: Automatically includes Node.js 18, git, and ripgrep

Quick Start

  1. Clone or download these files to a directory
  2. Enter the Nix shell:
    nix-shell
  3. Run claude-code (it will auto-install on first use):
    claude

Installation Methods

Method 1: Temporary Shell (for testing)

cd /path/to/this/directory
nix-shell
claude

Method 2: System-wide (NixOS)

Add to your /etc/nixos/configuration.nix:

environment.systemPackages = [
  (import /path/to/claude-code.nix {})
];

Method 3: Home Manager

Add to your home-manager configuration:

home.packages = [
  (import /path/to/claude-code.nix {})
];

Method 4: Nix Profile (user-only)

nix-env -i -f claude-code.nix

Usage

  • Run Claude Code: claude
  • Update Claude Code: claude-update

File Structure

  • claude-code.nix: Main Nix derivation that creates the wrapper
  • shell.nix: Development shell for quick testing
  • README.md: This documentation

How It Works

The Nix derivation creates a wrapper script that:

  1. Sets up a user-local npm prefix (~/.local/share/claude-code/npm)
  2. Checks if claude-code is installed
  3. Installs it on first run if needed
  4. Executes claude-code with all provided arguments

This approach ensures:

  • No system-wide npm modifications
  • No sudo requirements
  • Easy updates via npm
  • Clean separation from system packages

Troubleshooting

If you encounter issues:

  1. Ensure you have at least 30 credits in your Anthropic account
  2. Check that ~/.local/share/claude-code has proper permissions
  3. Try manually removing the installation and letting it reinstall:
    rm -rf ~/.local/share/claude-code
    claude  # Will reinstall

Notes

  • Claude Code will be installed on first run, not during Nix build time
  • Updates are handled through npm, preserving the auto-update functionality
  • The installation is completely isolated to your user directory

About

Install claude code with nix in the user’s directory (supports npm auto-update)

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages