# amsynist/zero-darwin architecture

> Architecture diagram of the GitHub repository amsynist/zero-darwin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amsynist/zero-darwin
- Repository: https://github.com/amsynist/zero-darwin

## Overview

##### Main Components

a) Core System Layer
- Nix-Darwin (System Configuration)
- Home Manager (User Configuration)
- macOS System Integration

b) Configuration Modules
- Darwin Modules
- Home Manager Modules
- Custom Services
- System Settings

c) External Tools & Services
- Window Management (Yabai)
- Hotkey Daemon (skhd)
- Status Bar (Sketchybar)
- Terminal (WezTerm)
- Editor (Neovim)

**┌─────────────────────────────────────────────┐**
- macOS                     │
- ┤
- Nix-Darwin                    │
- ┬─────────────┬──────────────┤
- System       │  Services   │  Settings    │
- Configuration│  Layer      │  Layer       │
- ┴─────────────┴──────────────┘
- ↑               ↑            ↑
**┌─────────────────────────────────────────────┐**
- Home Manager                   │
- ┬─────────────┬──────────────┤
- User         │  Program    │  CLI         │
- Config       │  Config     │  Tools       │
- ┴─────────────┴──────────────┘

##### Component Relationships

- Configuration flow (flake.nix → modules)
- Service dependencies
- Data flow between components
- Integration points with macOS

##### Detailed Component Breakdown

For the Darwin Modules section:
**┌─────── Darwin Modules ──────┐**
- ┌─────────┐ ┌────────────┐ │
- Custom  │ │  Services  │ │
- ┘ └────────────┘ │
- ┌─────────┐ ┌────────────┐ │
- Settings │ │  System    │ │
- ┘ └────────────┘ │
- ┘

For the Home Manager section:
**┌─────── Home Manager ──────┐**
- ┌─────────┐ ┌──────────┐ │
- Programs │ │ CLI Pkgs │ │
- ┘ └──────────┘ │
- ┌─────────┐ ┌──────────┐ │
- Manual  │ │  Config  │ │
- ┘ └──────────┘ │
- ┘

##### Implementation Notes

- Maintain consistent spacing and alignment
- Version information for major components
- Notes for critical configuration points

This system design should effectively communicate the architecture while maintaining the right level of detail for a principal software engineer to understand the system's structure and relationships.

Remember to emphasize the declarative nature of Nix configurations and how they propagate through the system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph OS["macOS Operating System"]
        MacOS["macOS Core"]
    end

    subgraph NixDarwin["Nix-Darwin Layer"]
        DarwinCore["Nix-Darwin Core"]:::core
        click DarwinCore "https://github.com/amsynist/zero-darwin/blob/master/modules/darwin/default.nix"

        subgraph DarwinModules["Darwin Modules"]
            CustomModules["Custom Modules"]:::module
            click CustomModules "https://github.com/amsynist/zero-darwin/tree/master/modules/darwin/custom/"

            subgraph ServicesLayer["Services Layer"]
                Yabai["Window Manager (Yabai)"]:::service
                Skhd["Hotkey Daemon (skhd)"]:::service
                Sketchybar["Status Bar (Sketchybar)"]:::service
                click Yabai "https://github.com/amsynist/zero-darwin/blob/master/modules/darwin/services/yabai.nix"
                click Skhd "https://github.com/amsynist/zero-darwin/blob/master/modules/darwin/services/skhd.nix"
                click Sketchybar "https://github.com/amsynist/zero-darwin/blob/master/modules/darwin/services/sketchybar.nix"
            end

            subgraph SettingsLayer["Settings Layer"]
                SysEnv["System Environment"]:::settings
                NixSettings["Nix Settings"]:::settings
                click SysEnv "https://github.com/amsynist/zero-darwin/blob/master/modules/darwin/settings/environment.nix"
                click NixSettings "https://github.com/amsynist/zero-darwin/blob/master/modules/darwin/settings/nix-settings.nix"
            end
        end
    end

    subgraph HomeManager["Home Manager Layer"]
        HMCore["Home Manager Core"]:::core
        click HMCore "https://github.com/amsynist/zero-darwin/blob/master/modules/home-manager/default.nix"

        subgraph UserConfig["User Configuration"]
            ProgConfig["Program Configurations"]:::config
            CLITools["CLI Tools & Packages"]:::tools
            click ProgConfig "https://github.com/amsynist/zero-darwin/tree/master/modules/home-manager/programs/"
            click CLITools "https://github.com/amsynist/zero-darwin/blob/master/modules/home-manager/cliPkgs.nix"
        end

        subgraph Apps["Applications"]
            WezTerm["Terminal (WezTerm)"]:::app
            Neovim["Editor (Neovim)"]:::app
            click WezTerm "https://github.com/amsynist/zero-darwin/blob/master/modules/home-manager/programs/wezterm.nix"
            click Neovim "https://github.com/amsynist/zero-darwin/tree/master/modules/home-manager/programs/nixvim/"
        end
    end

    %% Configurations
    subgraph Configs["Configuration Files"]
        SketchybarConfig["Sketchybar Config"]:::config
        WeztermConfig["WezTerm Config"]:::config
        click SketchybarConfig "https://github.com/amsynist/zero-darwin/tree/master/configs/sketchybar/sketchybarrc"
        click WeztermConfig "https://github.com/amsynist/zero-darwin/blob/master/configs/wezterm/wezterm.lua"
    end

    %% Relationships
    MacOS --> DarwinCore
    DarwinCore --> CustomModules
    DarwinCore --> ServicesLayer
    DarwinCore --> SettingsLayer
    HMCore --> UserConfig
    HMCore --> Apps
    Sketchybar --> SketchybarConfig
    WezTerm --> WeztermConfig

    %% Styles
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px
    classDef module fill:#57a773,stroke:#000
    classDef service fill:#ff8c42,stroke:#000
    classDef settings fill:#848484,stroke:#000
    classDef config fill:#41b3a3,stroke:#000
    classDef tools fill:#e8a87c,stroke:#000
    classDef app fill:#c38d9e,stroke:#000

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        ModuleComp["Module"]:::module
        ServiceComp["Service"]:::service
        SettingsComp["Settings"]:::settings
        ConfigComp["Configuration"]:::config
        ToolsComp["Tools"]:::tools
        AppComp["Application"]:::app
    end
```
