# danielkosgei/nix-config architecture

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

- Interactive diagram: https://gitdiagram.com/danielkosgei/nix-config
- Repository: https://github.com/danielkosgei/nix-config

## Overview

##### Main Components
- Flake Entrypoint: At the root, the flake.nix file is the central piece that aggregates inputs (like the nixpkgs channel, Home Manager, and Hyprland package) and outputs the NixOS configurations.
- Host Configurations: Under the hosts directory there are distinct folders (e.g., hosts/shadow and hosts/reaper), each containing its own configuration.nix, hardware-configuration.nix, and home.nix (for user configuration via Home Manager).
- Home Manager Modules: The modules/home-manager directory contains subdirectories for “development” (IDEs, development tools) and “programs” (configurations for various applications like hyprland, mpv, waybar, wofi, zathura, and miscellaneous configurations). This separation allows for reusability and modularity when enabling or customizing user sessions.
- Topology and Result: The topology.nix and any build result indicate how the overall configuration is assembled and versioned.

##### Relationships and Interactions
- The flake.nix is the entry point which “ties” the entire configuration together. It imports inputs from external repositories and links to the outputs that are the NixOS configurations.
- Each host has system-level configuration (e.g., networking, bootloader, filesystems, etc.) defined in their configuration.nix and hardware-configuration.nix. Additionally, the home.nix file in a host directory integrates Home Manager for user-specific settings.
- The home-manager modules provide granular configuration for various aspects of the desktop environment and programs. These modules are referenced through the system configuration and thus interact indirectly with the host-level configuration.
- The flow is essentially: Flake.nix (global configuration) → Hosts (system configuration per machine) → Home Manager (user-level configurations via modules).

##### Architectural Patterns and Design Principles
- Modularity: The separation between system configuration (hosts/*) and user configuration (modules/home-manager) encourages modular design and isolated configuration changes.
- Declarative Configuration: All settings are defined “as code,” consistent with NixOS philosophies.
- Layered Abstraction: A clear layering exists from the flake (global inputs and outputs), to host-specific system configurations, down to individual user application configurations provided by Home Manager.
- Reusability: Home Manager modules and shared program configurations (grouped by category like development and miscellaneous) allow reusing settings across configurations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Configuration
    subgraph "Global Configuration"
        A["flake.nix\n(integrates nixpkgs, home-manager, hyprland)"]:::global
        B["topology.nix\n(Global topology config)"]:::global
        C["flake.lock\n(Global version lock)"]:::global
        A --> B
        B --> C
    end

    %% Hosts
    A --> D["Host: shadow"]:::system
    A --> E["Host: reaper"]:::system

    subgraph "Host: shadow"
        D1["configuration.nix"]:::system
        D2["hardware-configuration.nix"]:::system
        D3["home.nix\n(Home Manager integration)"]:::user
        D1 --- D2
        D1 --- D3
        D2 --- D3
    end

    subgraph "Host: reaper"
        E1["configuration.nix"]:::system
    end

    %% Home Manager Modules (User Level)
    D3 --> F["Home Manager Modules"]:::user
    subgraph "Home Manager Modules"
        F1["Development Modules"]:::modules
        F2["Programs Modules"]:::modules
    end

    %% Programs modules breakdown
    F2 --> G["Hyprland"]:::modules
    F2 --> H["Hyprlandia"]:::modules
    F2 --> I["Misc"]:::modules
    F2 --> J["MPV"]:::modules
    F2 --> K["Waybar"]:::modules
    F2 --> L["Waybarbak"]:::modules
    F2 --> M["Wofi"]:::modules
    F2 --> N["Zathura"]:::modules

    %% Click Events
    click A "https://github.com/danielkosgei/nix-config/blob/main/flake.nix"
    click B "https://github.com/danielkosgei/nix-config/blob/main/topology.nix"
    click D1 "https://github.com/danielkosgei/nix-config/blob/main/hosts/shadow/configuration.nix"
    click D2 "https://github.com/danielkosgei/nix-config/blob/main/hosts/shadow/hardware-configuration.nix"
    click D3 "https://github.com/danielkosgei/nix-config/blob/main/hosts/shadow/home.nix"
    click E1 "https://github.com/danielkosgei/nix-config/blob/main/hosts/reaper/configuration.nix"
    click F1 "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/development"
    click G "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/hyprland"
    click H "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/hyprlandia"
    click I "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/misc"
    click J "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/mpv"
    click K "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/waybar"
    click L "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/waybarbak"
    click M "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/wofi"
    click N "https://github.com/danielkosgei/nix-config/tree/main/modules/home-manager/programs/zathura"

    %% Styles
    classDef global fill:#ffcccc,stroke:#b30000,stroke-width:2px;
    classDef system fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef user fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef modules fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
