A comprehensive, reproducible macOS development environment using Nix, nix-darwin, and home-manager. Perfect for developers who want a declarative, version-controlled system configuration.
Nix is a package manager that treats packages as isolated, immutable units. Each package is stored with a unique hash in /nix/store/, ensuring:
- Zero Conflicts: Multiple versions of a package can exist together without conflict
- Perfect Reproducibility: Same configuration = same environment, everywhere
- Rollback Capability: Every change is reversible
- Declarative Configuration: Your entire system as code
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/salemaljebaly/mac-dev-setup/main/install.sh)"# Clone the repository
git clone https://github.com/salemaljebaly/mac-dev-setup.git ~/.config/nix-config
cd ~/.config/nix-config
# Run the installer
./install.sh- Editors: VSCode, Cursor
- Mobile Development: Android Studio, Xcode (automated installation)
- Containers: Docker Desktop
- Version Control: Git with enhanced configuration
- Package Managers: Homebrew (managed by Nix)
- Communication: Slack
- Design: Figma
- AI Assistant: ChatGPT Desktop
- Laravel Development: Herd
- VPN: ProtonVPN, WireGuard, Cloudflare Warp
- Terminal: Wave Terminal
- File Sharing: LocalSend
- Automation: fastlane
This setup uses a modular architecture:
- nix-darwin: System-level configuration and macOS preferences
- home-manager: User-specific configurations and dotfiles
- nix-homebrew: Declarative Homebrew management
- Flakes: Reproducible, version-locked dependencies
- For Nix packages, edit
home/common/packages.nix:
myPackages = with pkgs; [
# Add your package here
neovim
];- For Homebrew casks, edit
modules/system/homebrew.nix:
casks = [
# Add your cask here
"discord"
];- For App Store apps, edit
modules/system/homebrew.nix:
masApps = {
"App Name" = APP_ID;
};# Apply system changes (recommended method)
# if command not work, just run with sudo privileges
nix run nix-darwin -- switch --flake .Note: darwin-rebuild requires sudo privileges to modify system configurations. It will prompt for your password.
nix run nix-darwin -- switch --dry-run --flake .nix flake checknix run nix-darwin -- --list-generationsnix run nix-darwin -- switch --rollbackflake.nix- Main entry point and dependency managementhosts/- Machine-specific configurationshome/- User environment configurationsmodules/- Reusable configuration modules
-
"error: experimental Nix feature 'nix-command' is disabled"
- This happens when using sudo with Nix commands
- Solution: Use
nix --extra-experimental-features "nix-command flakes" run ... - Or ensure
/etc/nix/nix.confcontainsexperimental-features = nix-command flakes
-
"system activation must now be run as root"
darwin-rebuildrequires sudo privileges- The installer handles this automatically
- For manual runs: darwin-rebuild will prompt for sudo
-
"$HOME is not owned by you" when using sudo
- This is normal when sudo changes to root user
- Use absolute paths instead of relative paths with sudo
-
Homebrew casks fail to install
- Ensure Xcode Command Line Tools are installed:
xcode-select --install
- Ensure Xcode Command Line Tools are installed:
-
Permission denied errors
- Some apps need manual permission grants in System Preferences > Security & Privacy
-
Can't find applications
- GUI apps are in
/Applications/Nix Apps/ - Add to Spotlight: System Preferences > Spotlight > Privacy
- GUI apps are in
-
"darwin-rebuild: command not found" after installation
- This happens on first install before PATH is updated
- Solution 1: Open a new terminal window
- Solution 2: Run
source /etc/static/zshrc(or bashrc) - Solution 3: Run
./activate.shfrom the repository - Solution 4: Use full path:
/run/current-system/sw/bin/darwin-rebuild
# Uninstall nix-darwin
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A uninstaller
./result/bin/darwin-uninstaller
# Uninstall Nix
/nix/nix-installer uninstallWe welcome contributions! Here's how you can help:
- Test the tool on your Mac and report any issues
- Add new packages or configurations
- Improve documentation
- Share your experience
Please open an issue with:
- Your macOS version
- Error messages
- Steps to reproduce
- Fork the repository
- Create a feature branch
- Make your changes
- Run
make testto ensure quality - Submit a PR with a clear description
feat:New featuresfix:Bug fixesdocs:Documentation changesstyle:Code style changesrefactor:Code refactoringtest:Test additions or modificationschore:Maintenance tasks
This project is open source and available under the MIT License.
- nix-darwin maintainers
- home-manager community
- Determinate Systems for the improved Nix installer
- Nix Pills - Learn Nix fundamentals
- nix-darwin Manual
- home-manager Manual
- Nix Flakes - Understanding flakes
Built with β€οΈ for the developer community. Contributions welcome!