Opinionated nix-darwin and Home Manager configuration for bringing a clean macOS install up to a reproducible workstation in one rebuild.
-
Install Nix on macOS (if it is not already installed):
sh <(curl -L https://nixos.org/nix/install) -
Clone the dotfiles and enter the repository:
git clone https://github.com/mikesplain/dotfiles.git ~/.dotfiles cd ~/.dotfiles
-
Perform the first system activation with the same command CI runs:
nix run nix-darwin/master#darwin-rebuild --extra-experimental-features "nix-command flakes" -- switch --flake .
-
For day-to-day updates after the initial activation:
darwin-rebuild switch --flake . -
Drop into the development shell whenever you need project tooling (
nixfmt,prettier, git hooks, etc.):nix develop
For first-time setups, ./bootstrap.sh installs basic prerequisites before the Nix rebuild, while the flake handles all macOS and user configuration on subsequent runs.
flake.nix # Single entry point wiring hosts, Home Manager, and shared inputs
flake.lock # Pinned flake inputs
darwin/ # macOS (nix-darwin) modules
default.nix # Base host configuration
homebrew.nix # Brew taps/casks (kept OS-specific)
home/ # Home Manager modules (per-user programs, services, dotfiles)
default.nix # Aggregates user-level modules
git.nix # Git configuration and templates
programs.nix # CLI and application enablement
shell.nix # Shell environment (zsh, completions)
tmux.nix # Tmux defaults and theme
templates/ # Reusable text assets (gitconfig templates, placeholder secrets)
devshell.nix # Development shell definition for contributors
bootstrap.sh # Convenience script for bootstrapping fresh machines
darwin-rebuild switch --flake .— Apply configuration changes to the current machine.nix develop— Enter the dev shell with formatters and pre-commit hooks configured.pre-commit run --all-files— Lint and format Nix and text assets to match CI.nix flake update— Refresh inputs and rewriteflake.lockwhen bumping dependencies.
- Run
darwin-rebuild switch --flake .(or the CI command from Quick Start) after edits to confirm the macOS build succeeds. - Use
nix flake checkto evaluate Home Manager modules on bothaarch64-darwinandx86_64-darwin. - Source the interactive shell with
zsh -vc "source ~/.zshrc"to ensure the login environment stays clean.
If you hit a mount error while reinstalling Nix, ensure /sbin is on your PATH:
export PATH="/sbin:${PATH}"
sh <(curl -L https://nixos.org/nix/install)# Ensure nixpkgs is configured
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel --update
# Remove the nix-darwin configuration (may require multiple runs)
nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller
# Uninstall Nix itself
/nix/nix-installer uninstall
# Troubleshoot any disk access issues
/usr/sbin/diskutil
/bin/launchctl