System configuration for macOS (nix-darwin) and NixOS, with home-manager for the user environment.
Install Nix and Homebrew if not already present:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Clone and run the first-time switch (darwin-rebuild doesn't exist yet on a fresh machine):
git clone <repo-url> ~/dotfiles
cd ~/dotfiles
sudo nix run nix-darwin -- switch --flake .#jmbpAfter the first run, use just rebuild for all subsequent applies.
Clone the repo, add your generated hardware config, then switch:
git clone <repo-url> ~/dotfiles
nixos-generate-config --show-hardware-config > ~/dotfiles/hosts/nixos/hardware-configuration.nix
cd ~/dotfiles
nixos-rebuild switch --flake .#nixosAdd hardware-configuration.nix to the imports list in hosts/nixos/default.nix, then commit it. After the first switch, just rebuild-nixos works.
The orbstack host (hosts/orbstack) uses the NixOS LXC container module instead of a generated hardware config — no nixos-generate-config needed.
Note:
hosts/orbstack/default.nixhardcodesnetworking.hostName = "orbstack". If your OrbStack machine has a different name, update that value before applying.
git clone <repo-url> ~/dotfiles
cd ~/dotfiles
nixos-rebuild switch --flake .#orbstackCreate ~/.config/git/local with your identity:
[user]
name = Your Name
email = you@example.com
signingkey = ssh-ed25519 AAAA...
| Command | Description |
|---|---|
just rebuild |
Apply config changes (macOS) |
just rebuild-nixos |
Apply config changes (NixOS) |
just diff |
Preview what would change (macOS) |
just diff-nixos |
Preview what would change (NixOS) |
just update |
Update all flake inputs |
just update-input <input> |
Update a single flake input |
just check |
Validate the flake |
just gc |
Collect old generations and optimise the store |
macOS:
- Create
hosts/<hostname>/default.nixandhome.nix(copy fromhosts/jmbpas a starting point) - Add a
darwinConfigurations."<hostname>"entry toflake.nixusingmkHmConfig - Bootstrap on the new machine:
sudo nix run nix-darwin -- switch --flake .#<hostname>
NixOS:
- Create
hosts/<hostname>/default.nixandhome.nix(copy fromhosts/nixosas a starting point) - Add a
nixosConfigurations."<hostname>"entry toflake.nixusingmkHmConfig - Generate and commit
hardware-configuration.nixfor the machine - Bootstrap:
nixos-rebuild switch --flake .#<hostname>