This is my dotfiles repository. It uses Nix with flakes to manage my macOS system configuration. There are many like it, but this one is mine. You won't want to clone this whole repository, but feel free to explore and borrow what you like!
- Install Determinate Nix
- Clone these dotfiles to
~/dotfiles - Run initial installation:
nix run nix-darwin -- switch --flake ~/dotfiles# - Configure git hooks:
git config core.hooksPath .githooks
Subsequent updates: use system-update (--cleanup optional)
To configure a new macOS machine:
-
Copy the example host template:
cp -r hosts/example-macos hosts/your-hostname
-
Edit
hosts/your-hostname/default.nixand customize:hostname: Your machine's hostname (find withhostname)username: Your macOS usernamegitNameandgitEmail: Your Git identitygitSigningKey: Your SSH signing keycapabilities: Select the package sets you want installedmanagedDevice: Set totrueif on a corporate/managed devicemanageNix: Set tofalseif using Determinate Nix installer
See
hosts/example-macos/default.nixfor an example with available options. -
Add your host to
flake.nixin three places:a. In the
letblock, import the host configuration:# Import host configurations yourHostConfig = import ./hosts/your-hostname;
b. In the outputs, add to
darwinConfigurations:darwinConfigurations.${yourHostConfig.hostname} = mkDarwinSystem yourHostConfig;
c. In the
checkssection (within theoptionalAttrsfor darwin), add a validation check:your-hostname = self.darwinConfigurations.${yourHostConfig.hostname}.system;
-
Build and activate:
nix run nix-darwin -- switch --flake ~/dotfiles#