What Darwin modules provide
These modules adapt the NixOS configuration framework to work on macOS, handling the differences between Linux and Darwin while maintaining a consistent interface.System preferences
Dock, Finder, keyboard, trackpad, and other macOS settings
Homebrew integration
Declarative Homebrew package and cask management
Hardware settings
Keyboard layouts, trackpad configuration, and device preferences
Security
Firewall, FileVault, and security policies
Module categories
preferences/
macOS system preferences configured declaratively.dock.nix - Dock configuration
dock.nix - Dock configuration
Control the macOS Dock appearance and behavior.Hot corner options:
modules/darwin/preferences/dock.nix
1- Disabled2- Mission Control3- Application Windows4- Desktop5- Start Screen Saver10- Put Display to Sleep11- Launchpad13- Lock Screen
finder.nix - Finder preferences
finder.nix - Finder preferences
Configure Finder file browser settings.Includes:
- Default view style (icon, list, column, gallery)
- Show/hide hidden files
- Show file extensions
- Search scope defaults
- Path bar and status bar visibility
clock.nix - Menu bar clock
clock.nix - Menu bar clock
login.nix - Login window
login.nix - Login window
Login window appearance and behavior, including:
- Auto-login settings
- Guest account configuration
- Login window text
measurements.nix - Units and formats
measurements.nix - Units and formats
Regional settings for:
- Temperature units (Celsius/Fahrenheit)
- Measurement system (metric/imperial)
images.nix - Image handling
images.nix - Image handling
Screenshot location, format, and default image viewers.
sound.nix - Audio settings
sound.nix - Audio settings
Sound effects, volume, and audio device configuration.
misc.nix - Other preferences
misc.nix - Other preferences
Miscellaneous system preferences that don’t fit other categories.
hardware/
Hardware device configuration.keyboard.nix - Keyboard settings
keyboard.nix - Keyboard settings
Keyboard layout, modifier keys, and input settings.Configure:
- Key repeat rate and delay
- Modifier key remapping (Caps Lock to Control, etc.)
- Keyboard shortcuts
- Input sources and layouts
trackpad.nix - Trackpad configuration
trackpad.nix - Trackpad configuration
Trackpad gestures and sensitivity.Configure:
- Tap to click
- Natural scrolling direction
- Tracking speed
- Multi-finger gestures
- Force Click behavior
brew/
Homebrew package manager integration.Homebrew management
Homebrew management
Declaratively manage Homebrew packages, casks, and taps.The
brew/ modules provide:- Homebrew installation and updates
- Package installation from Homebrew
- Cask installation for GUI applications
- Tap management for third-party repositories
- Environment variable configuration
environment.nix - Homebrew paths
environment.nix - Homebrew paths
Sets up environment variables so Homebrew packages are available in your PATH.Automatically configures:
/opt/homebrew/binfor Apple Silicon/usr/local/binfor Intel Macs- Shell integration for bash, zsh, fish
security/
Security settings for macOS.Security features
Security features
- Firewall configuration
- FileVault encryption
- Gatekeeper settings
- Privacy controls
Top-level modules
These modules live directly in thedarwin/ directory:
nix.nix - Nix daemon configuration
nix.nix - Nix daemon configuration
Darwin-specific Nix daemon settings, including:
- Build users and groups
- Daemon socket configuration
- Auto-optimization settings
documentation.nix - Disable documentation
documentation.nix - Disable documentation
Disables man page generation to save disk space and build time.
system-packages.nix - System packages
system-packages.nix - System packages
Packages that should be available system-wide to all users.
config-path.nix - Configuration path
config-path.nix - Configuration path
Sets the path to the nix-darwin configuration for system management.
extras.nix - External modules
extras.nix - External modules
Imports external modules that don’t have a designated place in the structure.
legacy.nix - Compatibility shims
legacy.nix - Compatibility shims
Compatibility layer for options that need refactoring upstream.Provides backwards compatibility while the framework evolves.
Usage example
Here’s a complete example of configuring a macOS system:darwin-configuration.nix
Key features
Declarative system preferences
All macOS system preferences are declared in Nix configuration files. When you rebuild your system, preferences are automatically applied.Homebrew integration
Homebrew packages are declared alongside Nix packages, giving you access to both ecosystems. The framework handles installation and updates.Consistent with NixOS
Darwin modules mirror the structure and naming of NixOS modules where possible, making it easy to maintain configurations for both platforms.Base module inheritance
Darwin automatically imports base modules, sharing common configuration between macOS and NixOS systems.Differences from NixOS
macOS limitations mean some NixOS features aren’t available:- No systemd (uses launchd instead)
- Different user management system
- Limited kernel configuration
- Some services require Homebrew versions
Next steps
Home Manager modules
Per-user configuration that works on both NixOS and Darwin
Base modules
Shared configuration between platforms