Skip to content

salemaljebaly/mac-dev-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mac Development Environment with Nix

A comprehensive, reproducible macOS development environment using Nix, nix-darwin, and home-manager. Perfect for developers who want a declarative, version-controlled system configuration.

πŸ€” Why Nix?

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

πŸš€ Quick Start

One-Line Installation

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/salemaljebaly/mac-dev-setup/main/install.sh)"

Manual Installation

# 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

πŸ“‹ What's Included

Development Tools

  • 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)

Productivity Tools

  • Communication: Slack
  • Design: Figma
  • AI Assistant: ChatGPT Desktop
  • Laravel Development: Herd

Utilities

  • VPN: ProtonVPN, WireGuard, Cloudflare Warp
  • Terminal: Wave Terminal
  • File Sharing: LocalSend
  • Automation: fastlane

πŸ—οΈ Architecture

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

🎯 Customization

Adding New Tools

  1. For Nix packages, edit home/common/packages.nix:
myPackages = with pkgs; [
  # Add your package here
  neovim
];
  1. For Homebrew casks, edit modules/system/homebrew.nix:
casks = [
  # Add your cask here
  "discord"
];
  1. For App Store apps, edit modules/system/homebrew.nix:
masApps = {
  "App Name" = APP_ID;
};

Rebuilding After Changes

# 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.

πŸ§ͺ Testing Your Configuration

Dry Run

nix run nix-darwin -- switch --dry-run --flake .

Check Configuration

nix flake check

List Generations

nix run nix-darwin -- --list-generations

Rollback

nix run nix-darwin -- switch --rollback

πŸ“ Directory Structure

  • flake.nix - Main entry point and dependency management
  • hosts/ - Machine-specific configurations
  • home/ - User environment configurations
  • modules/ - Reusable configuration modules

πŸ”§ Troubleshooting

Common Issues

  1. "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.conf contains experimental-features = nix-command flakes
  2. "system activation must now be run as root"

    • darwin-rebuild requires sudo privileges
    • The installer handles this automatically
    • For manual runs: darwin-rebuild will prompt for sudo
  3. "$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
  4. Homebrew casks fail to install

    • Ensure Xcode Command Line Tools are installed: xcode-select --install
  5. Permission denied errors

    • Some apps need manual permission grants in System Preferences > Security & Privacy
  6. Can't find applications

    • GUI apps are in /Applications/Nix Apps/
    • Add to Spotlight: System Preferences > Spotlight > Privacy
  7. "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.sh from the repository
    • Solution 4: Use full path: /run/current-system/sw/bin/darwin-rebuild

Reset Everything

# 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 uninstall

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Test the tool on your Mac and report any issues
  2. Add new packages or configurations
  3. Improve documentation
  4. Share your experience

Found a Bug?

Please open an issue with:

  • Your macOS version
  • Error messages
  • Steps to reproduce

Want to Contribute?

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run make test to ensure quality
  5. Submit a PR with a clear description

Conventional Commits

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • style: Code style changes
  • refactor: Code refactoring
  • test: Test additions or modifications
  • chore: Maintenance tasks

πŸ“ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

πŸ“š Resources


Built with ❀️ for the developer community. Contributions welcome!

About

Mac Development Environment with Nix

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published