This is my dotfiles repository. It uses Nix with flakes to manage my system configurations. 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)
Initial installation from the NixOS live environment:
These steps assume hosts/<hostname> exists and is exposed from flake.nix
as nixosConfigurations.<hostname>. For a new machine, add the host first
using the "Adding a New NixOS Host" section.
-
Partition and mount the target system under
/mnt. -
Generate hardware configuration:
sudo nixos-generate-config --root /mnt
-
Clone these dotfiles somewhere under
/mnt, for example:sudo mkdir -p /mnt/etc/nixos sudo git clone <repo-url> /mnt/etc/nixos/dotfiles
-
Replace the bootstrap hardware configuration with the generated one:
sudo cp /mnt/etc/nixos/hardware-configuration.nix \ /mnt/etc/nixos/dotfiles/hosts/<hostname>/hardware-configuration.nix
The committed bootstrap file assumes root is labeled
nixosand the EFI system partition is labeledboot. Replacing it with generated hardware config is preferred once disk layout is final. -
Review
hosts/<hostname>/default.nixand update:hostnameusernamegitEmailgitSigningKey- any capability set changes
-
Install:
sudo nixos-install --flake /mnt/etc/nixos/dotfiles#<hostname>
-
After first boot, clone these dotfiles to
~/dotfilesand usesystem-updatefor subsequent updates:system-update
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#
To configure a new NixOS machine:
-
Copy the example host template:
cp -r hosts/example-nixos hosts/your-hostname
-
Edit
hosts/your-hostname/default.nixand customize:hostname: Your machine's hostnameusername: Your Linux usernamesystem: Usuallyx86_64-linuxcpuVendor:intel,amd, ornullgitName,gitEmail, andgitSigningKeycapabilities: Select package sets to installhardwareModules: Include the generated hardware configuration
-
Add your host to
flake.nix:- import the host config
- expose it under
nixosConfigurations - add a target-system check under
checks
-
Build and activate:
sudo nixos-rebuild switch --flake ~/dotfiles#your-hostname