# hikuohiku/dots-nix architecture

> Architecture diagram of the GitHub repository hikuohiku/dots-nix, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hikuohiku/dots-nix
- Repository: https://github.com/hikuohiku/dots-nix

## Overview

##### Main Components Identification
- Dotfiles Management Core: At the heart of the system is the flake.nix and flake.lock which define and pin the overall configuration.
- Host Configurations: The “hosts” directory contains subdirectories for various operating systems (e.g., Darwin, NixOS, home) and even specific machines, defining machine-specific settings.
- Module Collections: Under “modules” you have further breakdowns—modules for Darwin (which include tools like yabai, amethyst, and browser configurations), modules for home (with sections for CLI tools, editors, fonts, terminal, overlays, etc.), and modules for NixOS (basic OS configuration modules).
- Additional User Configurations: The “config” directory holds extra configurations (such as fcitx settings) that integrate with the rest of the repository.
- CI/Automation: The “.github/workflows” folder contains automation scripts (like auto-update and check workflows) that help maintain the consistency and quality of these configurations.

##### Relationships and Interactions
- The flake files act as the central integration point. They reference modules and host directories.
- Host-specific files (found under hosts/*) import or reference one or more of the modules to build complete system configurations.
- Modules provide reusable configuration pieces (for desktop environments, applications, or system tools) that are then assembled in each host configuration.
- The CI workflows are “external services” that ensure these configurations are auto-updated and validated through continuous integration, linking back to the flake definitions.

##### Architectural Patterns and Design Principles
- Modularity: Configurations are segmented by both host type (e.g., Darwin vs. NixOS) and domain (e.g., terminal, browser, editor). This separation of concerns is key.
- Reusability: Modules are written to be reused across different hosts. A shared module (such as one for fonts or gui-tools) might be imported by several host-specific configurations.
- Declarative Infrastructure: The use of Nix flakes emphasizes a declarative model where system state is fully described in version-controlled files.
- Automation/CI Integration: GitHub workflows ensure that changes are automatically validated and periodically updated.

##### Relevant Technologies and Frameworks
- Nix/NixOS: For declarative system configuration.
- Nix Flakes: The project uses flakes to lock versions and manage dependencies.
- GitHub Actions: For continuous integration and automated task execution.
- Platform-Specific Tools: (e.g., yabai, amethyst, fcitx) represented as modules that provide configurations dedicated to each technology.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Dotfiles Management Core"
        FN["flake.nix"]:::flake
        FL["flake.lock"]:::flake
    end

    subgraph "Host Configurations"
        H_Darwin["Darwin Host"]:::host
        H_NixOS["NixOS Host"]:::host
        H_Home["Home Host"]:::host
    end

    subgraph "Module Collections"
        M_Darwin["Darwin Modules"]:::module
        M_NixOS["NixOS Modules"]:::module
        M_Home["Home Modules"]:::module
    end

    subgraph "Additional User Configurations"
        FC["fcitx Config"]:::config
    end

    subgraph "CI/Automation"
        CI_AU["auto-update Workflow"]:::ci
        CI_CH["check Workflow"]:::ci
    end

    %% Connections from Dotfiles Management Core to Host Configurations and Module Collections
    FN -->|"references"| H_Darwin
    FN -->|"references"| H_NixOS
    FN -->|"references"| H_Home

    FN -->|"includes"| M_Darwin
    FN -->|"includes"| M_NixOS
    FN -->|"includes"| M_Home

    %% Hosts import their respective modules
    H_Darwin -->|"imports"| M_Darwin
    H_NixOS  -->|"imports"| M_NixOS
    H_Home   -->|"imports"| M_Home

    %% Additional user configuration linked to Home Host
    H_Home -->|"integrates"| FC

    %% CI workflows trigger flake updates
    CI_AU ---|"triggers"| FN
    CI_CH ---|"triggers"| FN

    %% Click Events for Dotfiles Management Core
    click FN "https://github.com/hikuohiku/dots-nix/blob/main/flake.nix"
    click FL "https://github.com/hikuohiku/dots-nix/blob/main/flake.lock"

    %% Click Events for Host Configurations
    click H_Darwin "https://github.com/hikuohiku/dots-nix/tree/main/hosts/darwin"
    click H_NixOS "https://github.com/hikuohiku/dots-nix/tree/main/hosts/nixos"
    click H_Home "https://github.com/hikuohiku/dots-nix/tree/main/hosts/home"

    %% Click Events for Module Collections
    click M_Darwin "https://github.com/hikuohiku/dots-nix/tree/main/modules/darwin"
    click M_NixOS "https://github.com/hikuohiku/dots-nix/tree/main/modules/nixos"
    click M_Home "https://github.com/hikuohiku/dots-nix/tree/main/modules/home"

    %% Click Event for Additional User Configurations
    click FC "https://github.com/hikuohiku/dots-nix/tree/main/config/fcitx"

    %% Click Events for CI/Automation
    click CI_AU "https://github.com/hikuohiku/dots-nix/blob/main/.github/workflows/auto-update.yml"
    click CI_CH "https://github.com/hikuohiku/dots-nix/blob/main/.github/workflows/check.yml"

    %% Styles
    classDef flake fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef host fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef module fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef config fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef ci fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
