# ernwong/dotfiles architecture

> Architecture diagram of the GitHub repository ernwong/dotfiles, 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/ernwong/dotfiles
- Repository: https://github.com/ernwong/dotfiles

## Overview

This repository is a collection of dotfiles and system configuration files for a NixOS environment, incorporating home-manager settings and custom packages. Its purpose is to manage system and user configurations in a reproducible, declarative manner via NixOS and flakes. It also includes continuous integration (via GitHub Actions) and static checking (with tools like Statix and deadnix) to ensure configuration quality.

##### Project Overview and Main Components
- That this is not a full-stack web application or standalone tool; it is a configuration repository that centralizes NixOS, home-manager, and related package configurations.
- The main components to highlight include:
- Flake Infrastructure: Represented by flake.nix and flake.lock files, which serve as the backbone for reproducible builds.
- System Configuration: configuration.nix along with host-specific configurations (found under the hosts directory such as kaiki.nix and yoroizuka.nix) for machine-specific overrides.
- Home-Manager Configuration: Represented by home-manager.nix which governs user-level environment settings.
- Package Definitions: The pkgs directory contains subdirectories with definitions and patches for various custom packages (e.g., logseq, openrct2, waveterm, soundfonts).
- Checks and Testing: The checks directory (with deadnix.nix, default.nix, statix.nix) along with statix.toml for static analysis of configuration quality.
- Continuous Integration: The .github/workflows directory for automated testing and update workflows.
- Supporting config files: Files like config.nu, init.vim, inputrc, lesskey, and starship.toml which manage shell, editor, and other environment configurations.

##### Relationships and Interactions
- That the central Flake (flake.nix) ties together all parts of the configuration—this is where system configurations, home-manager settings, and packages are composed.
- Dependencies where package definitions in the pkgs folder are integrated into both system and home configurations.
- Directional interactions between CI workflows and the repository’s checks (GitHub Actions triggering checks using the files in the checks directory) to validate configurations.
- Out how host-specific configuration (in the hosts folder) branches out from the central configuration.nix, indicating how different machines (e.g., kaiki, yoroizuka) might have slight deviations from a base configuration.

##### Architectural Patterns and Design Principles
- Declarative, reproducible configuration model provided by NixOS and Nix flakes.
- Modularity by separating concerns across system-level (configuration.nix), user-level (home-manager.nix), host-specific settings (hosts), and package definitions (pkgs).
- Use of automated validation (checks and CI workflows) as a best practice in configuration management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    flake["Flake (flake.nix/flake.lock)"]:::core
    sys["System Configuration (configuration.nix)"]:::config
    home["Home Manager (home-manager.nix)"]:::home
    host_kaiki["Host (kaiki.nix)"]:::host
    host_yoroizuka["Host (yoroizuka.nix)"]:::host
    pkgs["Packages (pkgs/)"]:::pkg
    logseq["logseq"]:::pkg
    openrct2["openrct2"]:::pkg
    waveterm["waveterm"]:::pkg
    soundfonts["soundfonts"]:::pkg
    ci["CI (GitHub Actions)"]:::ci
    checks["Checks (checks/, statix.toml)"]:::ci
    aux["Supporting Config Files"]:::aux
    configNu["config.nu"]:::aux
    initvim["init.vim"]:::aux
    inputrc["inputrc"]:::aux
    lesskey["lesskey"]:::aux
    starship["starship.toml"]:::aux

    %% Connections
    flake -->|"builds"| sys
    flake -->|"builds"| home
    flake -->|"includes"| pkgs
    flake -->|"triggers"| ci

    sys -->|"overrides"| host_kaiki
    sys -->|"overrides"| host_yoroizuka
    sys -->|"integrates"| aux

    home -->|"uses"| pkgs

    pkgs -->|"defines"| logseq
    pkgs -->|"defines"| openrct2
    pkgs -->|"defines"| waveterm
    pkgs -->|"defines"| soundfonts

    ci -->|"executes"| checks

    aux -->|"contains"| configNu
    aux -->|"contains"| initvim
    aux -->|"contains"| inputrc
    aux -->|"contains"| lesskey
    aux -->|"contains"| starship

    %% Click events
    click flake "https://github.com/ernwong/dotfiles/blob/master/flake.nix"
    click flake "https://github.com/ernwong/dotfiles/blob/master/flake.lock"
    click sys "https://github.com/ernwong/dotfiles/blob/master/configuration.nix"
    click host_kaiki "https://github.com/ernwong/dotfiles/blob/master/hosts/kaiki.nix"
    click host_yoroizuka "https://github.com/ernwong/dotfiles/blob/master/hosts/yoroizuka.nix"
    click home "https://github.com/ernwong/dotfiles/blob/master/home-manager.nix"
    click pkgs "https://github.com/ernwong/dotfiles/tree/master/pkgs/"
    click logseq "https://github.com/ernwong/dotfiles/tree/master/pkgs/logseq"
    click openrct2 "https://github.com/ernwong/dotfiles/tree/master/pkgs/openrct2"
    click waveterm "https://github.com/ernwong/dotfiles/tree/master/pkgs/waveterm"
    click soundfonts "https://github.com/ernwong/dotfiles/tree/master/pkgs/soundfonts"
    click ci "https://github.com/ernwong/dotfiles/tree/master/.github/workflows/"
    click checks "https://github.com/ernwong/dotfiles/tree/master/checks/"
    click configNu "https://github.com/ernwong/dotfiles/blob/master/config.nu"
    click initvim "https://github.com/ernwong/dotfiles/blob/master/init.vim"
    click inputrc "https://github.com/ernwong/dotfiles/tree/master/inputrc"
    click lesskey "https://github.com/ernwong/dotfiles/tree/master/lesskey"
    click starship "https://github.com/ernwong/dotfiles/blob/master/starship.toml"

    %% Styles
    classDef core fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef config fill:#99ccff,stroke:#333,stroke-width:2px;
    classDef home fill:#99ff99,stroke:#333,stroke-width:2px;
    classDef host fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef pkg fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef ci fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef aux fill:#ffff99,stroke:#333,stroke-width:2px;
```
