A unified approach to managing system configuration using Nix/Home-Manager for reproducible package management and Chezmoi for personal dotfile synchronization.
This repository combines the best of both worlds:
- Nix/Home-Manager: Declarative, reproducible system package management
- Chezmoi: Flexible, templated personal configuration management
~/dotfiles/
βββ nix-darwin/ # macOS system configuration (includes Home-Manager)
β βββ flake.nix # Flake with nix-darwin, Home-Manager, and nix-homebrew
β βββ configuration.nix # System-level macOS configuration
β
βββ home-manager/ # Standalone Home-Manager (for non-macOS systems)
β βββ flake.nix # Flake definition for reproducible builds
β βββ flake.lock # Locked dependencies
β βββ home.nix # User packages and configuration
β
βββ chezmoi/ # Chezmoi-managed personal configs
β βββ .chezmoiignore # Files for Chezmoi to ignore
β βββ dot_gitconfig # Git configuration
β βββ dot_vimrc # Vim configuration
β βββ dot_config/ # .config directory files
β β βββ git/
β β β βββ kevinmichaelchen # Personal git config for GitHub repos
β β βββ opencode/ # OpenCode AI coding agent config
β β β βββ opencode.json
β β βββ shell/
β β β βββ bat.sh # bat aliases and functions (cat, batdiff, help)
β β β βββ git.sh # Shell-agnostic git aliases
β β β βββ openrouter.sh.tmpl # OpenRouter API key (1Password)
β β β βββ fireworks.sh.tmpl # Fireworks API key (1Password)
β β β βββ ... # Other shell configs
β β βββ mise/
β β β βββ config.toml # Mise version manager config (node, npm packages)
β β βββ starship.toml # Starship prompt configuration
β β βββ zsh/
β β βββ custom.zsh # Zsh configuration
β βββ dot_local/
β βββ share/
β βββ crush/ # Crush AI coding agent config
β βββ crush.json
β
βββ scripts/ # Helper automation scripts
βββ bootstrap.sh # Initial machine setup
βββ update.sh # Update both systems
On macOS, we use nix-darwin as the primary configuration manager with:
- nix-darwin: System-level configuration (dock, Finder, keyboard settings)
- nix-homebrew: Declarative Homebrew management (for macOS-only tools like vfkit)
- Home-Manager: Runs as a module within nix-darwin for user packages
- Chezmoi: Personal dotfile management
On Linux, we use:
- Home-Manager: Standalone user environment management
- Chezmoi: Personal dotfile management
Nix is a powerful package manager that makes package management reliable and reproducible. It provides:
- Declarative configuration: Define your entire system setup in code
- Reproducibility: Same configuration produces identical environments
- Rollbacks: Easy reversion to previous configurations
- No dependency hell: Each package gets its exact dependencies
nix-darwin provides declarative macOS system configuration:
- System preferences and defaults
- Homebrew package management
- Service management
- Integration with Home-Manager
Home-Manager is a Nix-based tool for managing user environments. It handles:
- Installing and configuring user packages
- Managing dotfiles through Nix
- Setting up development environments
- Configuring shells and terminal applications
Chezmoi is a sophisticated dotfile manager that provides:
- Templating: Machine-specific configurations
- Encryption: Secure secret management
- Version control: Git-based tracking
- Cross-platform: Works on Linux, macOS, and Windows
- Git
- Nix (install via Determinate Systems)
For a new machine, run:
curl -L https://raw.githubusercontent.com/kevinmichaelchen/dotfiles/main/scripts/bootstrap.sh | bashOr manually:
# Clone the repository
git clone https://github.com/kevinmichaelchen/dotfiles.git ~/dotfiles
cd ~/dotfiles
# Run the bootstrap script
./scripts/bootstrap.shThe bootstrap script will:
- Clone the dotfiles repository (if not already present)
- Verify Nix is installed (exits with instructions if not)
- Display clear next steps for completing the setup
After running the bootstrap script, you'll need to:
- Apply the system configuration (command provided by the script)
- Initialize Chezmoi after packages are installed
After the initial setup, complete these steps to enable 1Password CLI integration:
-
Download 1Password for macOS
- Download from 1Password.com or the Mac App Store
-
Enable 1Password CLI integration
- Open 1Password β Settings β Developer
- Enable "Integrate with 1Password CLI"
-
Apply Chezmoi configuration
chezmoi apply --source=$HOME/dotfiles/chezmoiNote: After applying Home-Manager, you can use the
cmaalias instead. -
Set up mise (Node.js and npm packages)
mise use node@24 # Install and activate Node.js mise install # Install npm packages from ~/.config/mise/config.toml
# On macOS
darwin-rebuild switch --flake ~/dotfiles/nix-darwin#default
# On Linux (standalone Home-Manager)
nix run home-manager -- switch --flake ~/dotfiles/home-manager
# Or use the shortcut (works on any system)
dot-update # Pulls latest changes and applies appropriate configuration# Edit package list
hme # Opens home.nix in your editor
# Apply changes (macOS)
darwin-rebuild switch --flake ~/dotfiles/nix-darwin#default
# Apply changes (Linux)
nix run home-manager -- switch --flake ~/dotfiles/home-manager# Edit a config file
cme ~/.vimrc # Opens in editor through Chezmoi
# View changes
cmd # Show diff of pending changes
# Apply changes
cma # Apply all Chezmoi-managed configs
# Add a new config file
chezmoi add ~/.some-configInitial setup script for new machines. It:
- Checks for and clones the dotfiles repository if needed
- Installs Nix (if not present) using Determinate Systems installer
- Provides colorful output with clear next steps
- Shows the exact commands to run for your system (macOS vs Linux)
Note: The script prepares your system but doesn't run commands requiring sudo. You'll need to run the provided commands manually to complete the setup.
Daily update script that:
- Pulls latest changes from git
- Updates and applies Home-Manager configuration
- Applies Chezmoi configuration changes
Following the "use Nix less" principle for better iteration speed and simplicity.
Home-Manager manages:
- Package installations (ripgrep, fd, chezmoi, zsh, starship, etc.)
- Enabling shells and tools (zsh with autosuggestions, syntax highlighting)
- Stable shell aliases (that rarely change)
- Development tools (rustc, cargo, mise, etc.)
- The base .zshrc file (for proper plugin initialization)
Chezmoi manages:
- Shell configuration (~/.config/zsh/custom.zsh, starship.toml)
- Personal configuration files (.gitconfig, .vimrc)
- Shell aliases and functions (via shell-agnostic scripts: bat.sh, git.sh, pnpm.sh, python.sh, zed.sh)
- Mise configuration (~/.config/mise/config.toml for Node.js and npm global packages)
- Machine-specific settings
- Secrets and API keys (encrypted)
- Quick-iteration configs
- Shell configs & prompts β Edit via Chezmoi for instant application
- New software packages β Add to home.nix for reproducible installation
- Frequently edited configs β Manage with Chezmoi
- Stable aliases β Keep in Home-Manager
- Cross-shell compatibility β Use shared scripts like git.sh
The configuration includes these helpful aliases:
dot- Navigate to dotfiles directorydot-update- Update everythingdr- Apply nix-darwin changes (includes Home-Manager)dru- Update flake and apply nix-darwindre- Edit nix-darwin configuration.nixhme- Edit Home-Manager home.nixcm- Chezmoi command (uses ~/dotfiles/chezmoi as source)cma- Apply Chezmoi changescmd- Show Chezmoi diffcme- Edit file with Chezmoicmu- Update Chezmoi
hme # Edit home.nix
# Add package to the list
dr # Apply changescme ~/.gitconfig # Edit via Chezmoi
cma # Apply changes# On source machine
git add -A
git commit -m "Update configs"
git push
# On target machine
dot-update # Pull and apply everythingThis repository is for personal configuration management. Feel free to use it as inspiration for your own dotfiles setup!