A modern, declarative macOS system configuration using nix-darwin and Home Manager.
-
Install Nix with flakes support:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
-
Clone and apply this configuration:
git clone <your-repo-url> ~/.config/nixpkgs cd ~/.config/nixpkgs nix flake update darwin-rebuild switch --flake .#MacBookPro
- TouchID authentication for sudo
- Application firewall enabled with stealth mode
- Secure system defaults
- Privacy-focused DNS (Cloudflare + Google)
- Editors: VS Code Insiders, Zed Preview, Neovim, Emacs
- Version Control: Git with delta diffs, GitHub CLI
- Languages: Go, Node.js, Rust, Python (uv), Lua
- Tools: Docker alternatives (OrbStack, Colima), Kubernetes tools, AWS CLI
- Window Management: Yabai + skhd for tiling
- Productivity: Raycast, Hammerspoon automation
- Fonts: Nerd Fonts collection for programming
- Terminal: Modern shell tools (bat, eza, fd, ripgrep, zoxide)
- Nix: Reproducible system and user packages
- Homebrew: GUI applications and tools not in nixpkgs
- Home Manager: Declarative user environment
This configuration follows modern Nix best practices:
- All dependencies managed through
flake.nix - Pinned inputs for reproducibility
- Support for both stable and unstable nixpkgs
- System Level:
darwin/- macOS system configuration - User Level:
home/- User-specific settings via Home Manager - Libraries:
lib/- Reusable helper functions - Custom Modules:
modules/- Extended functionality
- Legacy Compatibility:
default.nixvia flake-compat - Optimized Performance: Binary caches, auto-optimization enabled
- Apple Silicon Support: Native aarch64-darwin configuration
- Secure Defaults: Hardened system preferences
# Rebuild system configuration
darwin-rebuild switch --flake .
# Update all dependencies
nix flake update
# Check configuration before building
nix flake check
# Build without switching (for testing)
darwin-rebuild build --flake .# Clean up old generations
darwin-rebuild --list-generations
nix-collect-garbage -d
# Optimize Nix store
nix store optimise
# Update specific input
nix flake lock --update-input nixpkgs-unstableUpdate user details in flake.nix:
primaryUserDefaults = {
username = "pritamkadam";
fullName = "Pritam Kadam";
email = "[email protected]";
nixConfigDirectory = "~/.config/nixpkgs";
};- Nix packages: Add to
home/packages.nix - Homebrew casks: Add to
darwin/homebrew.nix - System tools: Add to
home/packages.nixor homebrew
Modify darwin/defaults.nix for:
- macOS system defaults
- Security settings
- UI preferences
.
βββ flake.nix # Main flake configuration
βββ flake.lock # Dependency lock file
βββ default.nix # Legacy compatibility
βββ darwin/ # macOS system configuration
β βββ defaults.nix # System defaults & security
β βββ general.nix # General system settings
β βββ homebrew.nix # Homebrew packages
β βββ bootstrap.nix # Minimal bootstrap config
βββ home/ # Home Manager configuration
β βββ packages.nix # User packages & programs
β βββ git.nix # Git configuration
β βββ fish.nix # Fish shell setup
β βββ *.nix # Other configurations
βββ lib/ # Reusable functions
β βββ mkDarwinSystem.nix # Darwin system builder
βββ modules/ # Custom modules
βββ darwin/
βββ users.nix # User management
- Fork this repository and customize the personal information
- Review packages in homebrew.nix and packages.nix
- Adjust system defaults in darwin/defaults.nix to your preferences
- Test the configuration with
darwin-rebuild build --flake . - Apply changes with
darwin-rebuild switch --flake .
- Build failures: Run
nix flake checkto validate syntax - Permission errors: Ensure you're in the admin group
- Homebrew conflicts: Avoid duplicate packages between Nix and Homebrew
This configuration is provided as-is for educational purposes. Feel free to use and modify.