Skip to content

rbright/nixos-config

Repository files navigation

Nix + macOS Configuration

A comprehensive, declarative macOS configuration using Nix flakes, nix-darwin, and home-manager. This configuration provides a reproducible development environment with carefully tuned system preferences, package management, and application settings.

🏗️ Architecture

This configuration uses a modular architecture combining:

  • Nix Flakes for reproducible builds and dependency management
  • nix-darwin for macOS system configuration
  • home-manager for user-level packages and dotfiles
  • nix-homebrew for declarative Homebrew management

💡 Key Features

  • Fully Reproducible Environment - Every setting, package, and preference is declared in code and version-controlled
  • Zero-Configuration Setup - Clone and run a single command to get a complete development environment
  • Atomic System Updates - Build and test changes before applying, with instant rollback capability
  • Hybrid Package Management - Combines Nix's reproducibility with Homebrew's macOS app ecosystem
  • Infrastructure-as-Code - Complete macOS system configuration managed through Nix modules

🚀 Getting Started

Initial Setup

  1. Install Nix (if not already installed):

    curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  2. Clone and bootstrap:

    git clone <this-repo>
    cd nixos-config
    just bootstrap
  3. Build and install:

    just install

Daily Usage

  • Update system: just update && just install
  • Install new software: Add to appropriate package list and run just install
  • Rollback changes: just rollback
  • Clean old generations: just clean

🛠️ Commands

All common operations are available through the just task runner:

Bootstrap & Setup

just bootstrap          # Bootstrap new macOS installation

Runs ./bootstrap.zsh to install Xcode CLI tools and Nix.

System Management

just build              # Build configuration without applying
just install            # Build and switch to new configuration
just rollback           # Rollback to previous generation
just list               # List all system generations

Maintenance

just update             # Update all flake inputs
just update-flake FLAKE # Update specific flake input
just clean              # Clean up old generations

Development

just                    # Show all available commands

🔧 Customization

Adding Packages

  • CLI tools: Add to modules/packages.nix
  • GUI apps: Add to modules/darwin/homebrew/casks.nix
  • Homebrew formulas: Add to modules/darwin/homebrew/brews.nix
  • Mac App Store: Add to homebrew masApps list

Modifying System Preferences

  • Edit relevant files in modules/darwin/
  • Each module handles specific system aspects (keyboard, finder, dock, etc.)
  • Run just install to apply changes

Custom Applications

  • Add dock entries in modules/darwin/dock/default.nix
  • Configure app-specific preferences in modules/darwin/applications/

📦 Package Management

This configuration uses a hybrid approach with four package managers:

Each package manager handles what it does best: Nix for reproducible development tools, Homebrew for macOS applications, and the Mac App Store for Apple ecosystem integration.

🔐 Security Features

  • Firewall enabled with stealth mode
  • Secure DNS (Cloudflare 1.1.1.1)
  • GPG integration with pinentry for macOS
  • No .DS_Store files on network/USB drives
  • Quarantine disabled for trusted applications
  • Auto-updates for critical security patches

📁 Directory Structure

nixos-config/
├── flake.nix              # Main flake configuration
├── flake.lock             # Pinned dependency versions
├── justfile               # Task runner commands
├── bootstrap.zsh          # Initial setup script
├── hosts/darwin/          # Host-specific configuration
├── modules/
│   ├── darwin/            # macOS system modules
│   │   ├── applications/  # App-specific preferences
│   │   ├── dock/          # Custom dock management
│   │   └── homebrew/      # Homebrew package lists
│   ├── packages.nix       # Nix package definitions
│   └── home-manager.nix   # User-level configuration
└── apps/                  # System management scripts

📋 Components

Component Description Location
Flake Configuration Main entry point defining inputs, outputs, and system configuration flake.nix
Darwin Host macOS system-level configuration and module imports hosts/darwin/
Darwin Modules Modular macOS system preferences and application settings modules/darwin/
Package Management Comprehensive package list modules/packages.nix
Home Manager User-level package management and service configuration modules/home-manager.nix
Homebrew Integration Declarative Homebrew casks, brews, and Mac App Store apps modules/darwin/homebrew/
Applications System management scripts (build, install, rollback) apps/
Bootstrap Script Initial system setup script for new macOS installations bootstrap.zsh
Task Runner Just commands for common operations justfile

Darwin System Modules

Module Description Location
Applications App-specific preferences (Activity Monitor, Spotlight, etc.) modules/darwin/applications/
Dock Custom declarative dock management with dockutil modules/darwin/dock/
Finder Finder preferences and file management settings modules/darwin/finder.nix
Keyboard Keyboard behavior and shortcuts modules/darwin/keyboard.nix
Networking Network configuration, DNS, and firewall settings modules/darwin/networking.nix
Desktop Window management and desktop behavior modules/darwin/desktop.nix
System Preferences Complete macOS system preferences coverage modules/darwin/*.nix

📖 Resources

About

Nix configuration for macOS

Topics

Resources

Stars

Watchers

Forks