macOS dotfiles for multiple machines using Nix flakes, nix-darwin, Home Manager, and nix-homebrew.
| Config | Hostname | User | Brew owner |
|---|---|---|---|
macbook |
tutods-macbook |
tutods |
tutods |
work |
daniel.a.sousa |
daniel.a.sousa |
admin.daniel.a.sousa |
# Nix (multi-user)
sh <(curl -L https://nixos.org/nix/install)
# Xcode Command Line Tools
xcode-select --installgit clone https://github.com/tutods/macos-setup.git ~/.dotfiles
cd ~/.dotfiles./nix.sh macbook # personal MacBook
./nix.sh work # work laptopThis builds and applies the full system configuration via darwin-rebuild switch. Fish is set as the default shell, App Store apps and VSCode marketplace extensions are all installed automatically — no post-deploy script needed.
On the work laptop, run
./nix.sh workfromadmin.daniel.a.sousa— the admin user owns Homebrew. Home Manager still configuresdaniel.a.sousaindependently.
Git name and email are not stored in this repo. Set them on each machine:
mkdir -p ~/.config/git
git config --file ~/.config/git/private user.name "Your Name"
git config --file ~/.config/git/private user.email "your@email.com"See docs/private-git-config.md for full details.
# Prevent sleep (built-in macOS caffeinate, expanded by fish as abbreviation)
caf # prevent display, idle and disk sleep (Ctrl-C to stop)
caffeinate -t 3600 # prevent sleep for 1 hour
# Rebuild and apply changes
./nix.sh macbook
# Build only (no apply, useful to check for errors)
./nix.sh macbook --build-only
# Force rebuild
./nix.sh macbook --force
# Clean up old Nix generations
nix-collect-garbage -d.
├── flake.nix # Entry point — defines mkDarwin and mkHost
├── lib/
│ └── mkHost.nix # Shared host factory (fish, home-manager, nix-homebrew)
├── modules/
│ ├── common.nix # Nix settings, timezone, store optimisation
│ ├── darwin/ # macOS defaults, security, networking, keyboard
│ └── packages/
│ ├── default.nix # Imports all package modules
│ ├── cli.nix # CLI tools (fd, gh, jq, httpie, …)
│ ├── development.nix # Dev tools and IDEs (terraform, WebStorm, …)
│ ├── media.nix # Media processing (ffmpeg, imagemagick, …)
│ └── fonts.nix # System fonts (JetBrains Mono, Nerd Fonts, …)
├── hosts/darwin/
│ ├── macbook/ # Personal MacBook
│ │ ├── default.nix # Calls mkHost with macbook values
│ │ ├── dock.nix # Dock layout
│ │ └── homebrew/ # Macbook-specific casks and MAS apps
│ └── work/ # Work laptop
│ ├── default.nix # Calls mkHost with work values
│ ├── dock.nix
│ └── homebrew/ # Work-specific casks (shared base from modules/)
├── home/
│ ├── programs/ # Shared Home Manager programs (fish, VSCode, etc.)
│ ├── tutods/ # tutods user config
│ └── daniel.a.sousa/ # Work user config
└── docs/ # Additional documentation
-
Create the host directory:
cp -r hosts/darwin/macbook hosts/darwin/new-machine
-
Edit
hosts/darwin/new-machine/default.nix— update themkHostcall:{ mkHost, ... }: { imports = [ ./dock.nix ./homebrew (mkHost { username = "newuser"; hostname = "new-machine"; brewUser = "newuser"; homeConfig = import ../../../home/newuser/default.nix; }) ]; }
-
Create the home config:
cp -r home/tutods home/newuser # edit home/newuser/default.nix to set the correct username/homeDirectory -
Register in
flake.nix:"new-machine" = mkDarwin "./hosts/darwin/new-machine";
-
Deploy:
./nix.sh new-machine
| What | Where |
|---|---|
| System-wide CLI tools | modules/packages/cli.nix |
| Development tools and IDEs | modules/packages/development.nix |
| Media processing tools | modules/packages/media.nix |
| Fonts | modules/packages/fonts.nix |
| Shared Homebrew casks (all machines) | modules/darwin/homebrew/casks/ |
| Machine-specific Homebrew casks | hosts/darwin/<name>/homebrew/casks/ |
| Mac App Store apps (shared) | modules/darwin/homebrew/mas.nix |
| Mac App Store apps (per machine) | hosts/darwin/<name>/homebrew/mas.nix |
| User programs (shell, editor, etc.) | home/programs/ |
# Remove old generations and free disk space
nix-collect-garbage -d
# If Homebrew has issues after a rebuild
brew doctorDependency updates are automated via Renovate — minor and patch updates for nixpkgs, home-manager, nix-darwin, and nix-homebrew are auto-merged. Major updates require manual review.