Personal Nix home-manager configuration for macOS (Apple Silicon) that manages user environment, packages, and dotfiles using Nix flakes.
- π Declarative Environment: Complete user environment managed through Nix
- π¦ Package Management: Reproducible package installation across machines
- π§ Development Tools: Comprehensive development environment setup
- π Flake-based: Modern Nix flakes for better reproducibility
- π macOS Optimized: Specifically configured for Apple Silicon Macs
- πΎ Binary Caches: Fast package installation with pre-built binaries
- βοΈ Global Direnv: Universal direnv integration across all terminals and editors
-
Install Nix (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
-
Install Home Manager:
nix run home-manager/master -- init --switch
-
Clone this repository:
git clone https://github.com/sadjow/home-manager ~/.config/home-manager cd ~/.config/home-manager
-
Apply the configuration:
home-manager switch --flake .
βββ flake.nix # Flake definition with inputs and outputs
βββ flake.lock # Locked dependency versions
βββ darwin-configuration.nix # nix-darwin system config (hostname, etc.)
βββ home.nix # Main home-manager configuration
βββ home/
β βββ nix/
β β βββ default.nix # Nix-specific settings and binary caches
β βββ claude-code.nix # Claude Code integration
β βββ mcp-servers.nix # MCP servers with 1Password integration
β βββ shell.nix # Shell configuration (zsh/bash with global direnv)
βββ docs/
β βββ CHANNEL_STRATEGY.md # Nixpkgs channel strategy and alternatives
βββ overlays/
β βββ README.md # Information about custom overlays
βββ CLAUDE.md # AI assistant guidance
βββ README.md # This file
- Languages: Ruby, Dart, Node.js (via asdf)
- Editors: Neovim
- Version Control: Git, GitHub CLI
- Build Tools: CocoaPods, FFmpeg
- Shell: tmux, direnv, ripgrep, bat
- Security: AWS Vault, GPG
- Network: nmap
- AI Tools: Claude Code (via external flake)
- Package Management: Cachix, asdf-vm
- devenv: Fast, declarative development environments
- claude-code: AI coding assistant with dedicated Node.js runtime
This configuration uses several binary caches for faster package installation:
- cache.nixos.org: Official Nix cache
- devenv.cachix.org: Devenv package cache
- nix-community.cachix.org: Community packages
- claude-code.cachix.org: Custom Claude Code builds
To ensure flake operations (including devenv updates) use the right caches without rebuilding locally, caches are declared at the flake level and accepted non-interactively:
- Flake-level caches are set in
flake.nixvianixConfig.extra-substitutersandnixConfig.extra-trusted-public-keys. - Non-interactive acceptance is enabled in
home/nix/default.nixvia:nix.settings.experimental-features = [ "nix-command" "flakes" ];nix.settings.accept-flake-config = true;
Verification:
# Show effective daemon config (should list cachix and devenv caches)
nix config show | grep -E 'substituters|trusted.*keys'
# Run flake commands without prompts
nix --accept-flake-config flake checkTroubleshooting:
- If prompts still appear, pass
--accept-flake-configon the command, or ensure Home Manager has applied the config:
home-manager switch --flake .- If packages still rebuild, the exact inputs may not be present in caches for your platform; otherwise, caching is correctly configured.
This configuration provides comprehensive direnv integration that works seamlessly across all terminals and editors:
- Universal Support: Works in VSCode, Cursor, and any terminal application
- Multi-shell: Supports both zsh and bash shells
- Login Shell Compatibility: Properly configured for login shells spawned by editors
- Auto-loading: Direnv hooks are loaded automatically without manual setup
The global direnv integration is implemented through:
- Profile-level hooks: Added to
.zprofileand.bash_profilefor login shells - Interactive shell integration: Built-in home-manager direnv support
- Global PATH configuration: Ensures direnv is available system-wide
- Redundant loading protection: Prevents duplicate initialization
# Test direnv in different shell contexts
zsh -l -c 'command -v _direnv_hook && echo "β direnv loaded in zsh"'
bash -l -c 'command -v _direnv_hook && echo "β direnv loaded in bash"'
direnv --version # Should show installed versionThis means when you open a project with a .envrc file in any editor, the environment will be automatically activated in all terminal sessions without additional configuration.
# Apply home-manager configuration
home-manager switch --flake .
# Apply nix-darwin system configuration
sudo darwin-rebuild switch --flake .#codecraft
# Build configuration without switching
home-manager build --flake .
# Preview changes (dry run)
home-manager switch --flake . -n
# Update flake dependencies
nix flake update
# Check configuration validity
nix flake check# Show flake outputs
nix flake show
# Update specific input
nix flake lock --update-input <input-name>
# Run garbage collection
nix-collect-garbage -dEdit home.nix and add packages to the home.packages list:
home.packages = [
pkgs.your-package
# ... other packages
];The configuration is modular. Key files to modify:
home.nix: Main package list and basic settingshome/nix/default.nix: Nix daemon settings and binary cacheshome/shell.nix: Shell configuration and direnv integrationflake.nix: Add new input flakes or change system configurations
To add a new binary cache, edit home/nix/default.nix:
caches = {
"cache.nixos.org" = "6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=";
"your-cache.cachix.org" = "your-public-key=";
# ... other caches
};- Flake-based: Uses Nix flakes for improved reproducibility and dependency management
- Modular: Configuration split into logical modules for easier maintenance
- macOS Optimized: Specifically configured for Apple Silicon (aarch64-darwin)
- External Dependencies: Important tools like Claude Code managed as separate flakes
- Binary Caching: Multiple cache sources for fast package installation
- Channel Strategy: Uses nixpkgs-unstable for latest packages (see Channel Strategy Documentation)
- Platform: macOS (Apple Silicon / aarch64-darwin)
- Nix Version: Compatible with Nix 2.19+
- Home Manager: Uses latest stable release
-
Flake evaluation errors:
nix flake check --show-trace
-
Binary cache issues:
nix store ping --store https://cache-url.org
-
Home Manager conflicts:
home-manager switch --flake . --show-trace
- Check the Home Manager manual
- Review the Nix flakes documentation
- See
CLAUDE.mdfor AI assistant specific guidance
- claude-code-nix: Dedicated Nix package for Claude Code
- devenv: Fast, declarative development environments
This configuration is provided as-is for personal use. Feel free to adapt it for your own needs.
Note: This configuration is personalized for user "sadjow". You'll need to update usernames, paths, and personal preferences when adapting it for your own use.