This repository contains my personal Nix Darwin configuration for macOS. It uses nix-darwin and home-manager to manage system and user configuration.
- Complete macOS system configuration via Nix
- Homebrew integration for additional software
- VS Code configuration with extensions
- Git, ZSH, and other developer tools
The configuration is organized into the following modules:
flake.nix: Main entry point with inputs and outputshosts/: Host-specific configurationdarwin/: macOS-specific system configurationsystem/: System-level settings (keyboard, preferences, security, etc.)apps/: Application-specific configuration (homebrew, etc.)
home/: User-specific configuration managed by home-managerpackages.nix: User packagesshell/: Shell configuration (zsh)programs/: User programs configuration (git, tmux, etc.)terminals/: Terminal emulators configuration (ghostty)
editors/: Code editor configuration (vim, vscode, zed)
config/: Configuration files for various applications
- Install Nix via Determinate Systems:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --determinate
-
Clone this repository:
git clone https://github.com/yourusername/nix-config.git ~/.config/nix cd ~/.config/nix
-
Create your personal configuration:
cp local.example.nix local.nix
-
Edit
local.nixwith your personal information:{ hostname = "your-macbook"; # Your machine's hostname username = "yourusername"; # Your macOS username fullName = "Your Full Name"; # Your name for Git commits email = "your.email@example.com"; # Your primary email githubEmail = "your.github.email@example.com"; # Email for GitHub architecture = "aarch64-darwin"; # or "x86_64-darwin" for Intel Macs }
-
Build and activate the configuration:
nix run nix-darwin/master#darwin-rebuild -- switch --flake .
To update your system:
cd ~/.config/nix
git pull
darwin-rebuild switch --flake ~/.config/nixOr simply use the alias defined in the configuration:
switch- Add packages in the appropriate module files
- Configure additional macOS settings in the
darwin/systemdirectory - Add Homebrew packages in
darwin/apps/homebrew.nix - Add new modules by creating files in the appropriate directories and importing them in the corresponding
default.nix
- Add new nix files to the appropriate directory based on the type of configuration
- Import the new file in the corresponding
default.nix - Rebuild with
switchcommand
If you see errors about the hostname not being found in the flake outputs:
- Check that your
local.nixfile contains the correct hostname - Try running with the full hostname:
darwin-rebuild switch --flake ~/.config/nix#your-hostname