A declarative macOS development environment using Nix Flakes, based on dustinlyons/nixos-config but streamlined specifically for Darwin/macOS systems.
Note: This configuration is personalized for user "patrick" and is not intended to be reusable as a template.
- Declarative System Configuration: Everything defined in code using Nix Flakes
- Automated Software Management:
- Nix packages: CLI tools, development environments, fonts
- Homebrew: GUI applications and some CLI tools
- Mac App Store: Apps managed via
mastool
- Dotfile Management: Automated deployment of configuration files (zsh, tmux, neovim, karabiner, etc.)
- Encrypted Secrets: Secure secret management with agenix and YubiKey support
- macOS System Defaults: Automated configuration of system preferences
- Automatic Cleanup: Removes unlisted Homebrew packages to keep system clean
- Xcode Command Line Tools:
xcode-select --install - Nix with Flakes: Install using Determinate Systems installer
- Enable Flakes: Ensure
experimental-features = nix-command flakesis enabled
# Clone the repository
git clone https://github.com/PatrickLerner/nix-config.git
cd nix-config
# Build and apply the configuration
nix run .#build-switch| Command | Description |
|---|---|
nix run .#build |
Test build without switching (safe) |
nix run .#build-switch |
Build and apply configuration (requires sudo) |
nix run .#clean |
Remove old system generations (7+ days) |
nix run .#rollback |
Rollback to previous generation (interactive) |
nix run .#check-keys |
Verify required SSH keys |
nix run .#create-keys |
Generate SSH keys |
nix develop |
Enter development shell |
The system configuration is organized across these key files:
- modules/shared/packages.nix - Nix packages (CLI tools, development environments)
- modules/darwin/casks.nix - Homebrew GUI applications
- modules/darwin/home-manager.nix - Homebrew formulas and Mac App Store apps
- modules/shared/home-manager.nix - Shell, git, tmux, and user configuration
- modules/shared/config/ - Application-specific configuration files
- hosts/darwin/default.nix - macOS system settings and defaults
- Nix packages: Edit
modules/shared/packages.nix - Homebrew casks: Edit
modules/darwin/casks.nix - Homebrew formulas: Edit
modules/darwin/home-manager.nixbrews array - Mac App Store: Edit
modules/darwin/home-manager.nixmasApps
- Shell & Terminal:
modules/shared/home-manager.nix - Application configs:
modules/shared/config/ - macOS settings:
hosts/darwin/default.nix - Dock:
modules/darwin/dock/
- Homebrew Casks: https://formulae.brew.sh/cask/
- Nix Packages: https://search.nixos.org/packages
- Mac App Store: Use
mas search <app name>after installation
- Detailed Configuration Guide: See CLAUDE.md
- Original Template: dustinlyons/nixos-config
- Build Failures: Try
nix run .#cleanthen rebuild - Permission Errors: Ensure SSH keys have correct permissions (600)
- Homebrew Conflicts: The system automatically removes unlisted packages
- System Recovery: Use
nix run .#rollbackto restore previous state
- Check existing issues in the original template repository
- Verify Nix experimental features are enabled
- Ensure Git user.name and user.email are configured before running apply