How the flake composes a full nix-darwin + Home Manager system.
.config/nix/flake.nix is the only entry point. It defines:
- A
commonModuleslist — the system-wide module set shared by every host - One
darwinConfigurations.<host>per host, built as[ ./hosts/<host> ] ++ commonModules
commonModules includes (see flake.nix for the authoritative list and order):
./modules/host-spec.nix— declares theconfig.hostSpecoptions./hosts/common— shared system packages and Homebrew package lists./darwin— system-level macOS settings, Nix settings, Homebrew toggles, agenixagenix.darwinModules.default— agenix integrationhome-manager.darwinModules.home-manager— Home Manager integration;users.<username>is set fromconfig.hostSpec.usernameand imports./home-managernix-homebrew.darwinModules.nix-homebrew— declarative Homebrew, also keyed offconfig.hostSpec.username
modules/host-spec.nix declares three options used throughout the tree:
hostSpec.hostName— networking hostnamehostSpec.username— primary user; drives Home Manager home dir, Homebrew owner, secret decryption pathshostSpec.isWork— gates work-only packages and secrets vialib.mkIf config.hostSpec.isWork
Each hosts/<host>/default.nix sets these values. Other modules consume them via config.hostSpec.*.
darwin/default.niximports the rest ofdarwin/(system prefs, nix, homebrew settings, secrets)home-manager/default.niximportspackages.nix,dotfiles.nix, and everything underprograms/hosts/common/default.niximports the threehomebrew*.nixpackage lists
Reading any of these default.nix files is the fastest way to see the current set of imports.
darwin-rebuild switch --flake .config/nix#<host>evaluatesdarwinConfigurations.<host>- The host module sets
hostSpec.*, network hostname,system.primaryUser, andusers.users.<username> commonModulesmerges in system, user, Homebrew, and agenix configuration — all parameterized byconfig.hostSpec.*- nix-darwin activates system settings; Home Manager activates user settings; nix-homebrew reconciles Homebrew; agenix decrypts secrets to the paths declared in
darwin/secrets.nix
Everything happens in a single atomic activation.
- System:
aarch64-darwin(Apple Silicon only) - Nix Flakes are required (experimental feature enabled in
darwin/nix.nix)