# gaetanlepage/nix-config architecture

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

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

## Overview

- Flake Infrastructure: At the center is the flake-based configuration management (files like flake.nix, flake.lock, and the flake/ directory) that ties the entire system together. This is the "source of truth" for the configurations.
- Operating System (NixOS) Configuration: Represented by the nixos/ directory. This includes system-wide configurations such as bootloader settings, hardware configurations, SSH keys, GitHub tokens, and remote builder setups.
- User-Specific Configurations (home-manager): The home/ directory holds the user-level configurations (hosts for different machines, modules for GUI and TUI, and various application settings such as for neovim, fish, and more).
- Secrets Management: The .secrets/ directory (along with subfolders under chamaeleon, cuda, and framework) holds sensitive keys and tokens. Indicate that these are used by both NixOS and home configurations (often via agenix or similar mechanisms) to handle sensitive data.
- Modular Configuration Components: The home/modules directory contains discrete modules (for GUI, TUI, etc.) that abstract away application-specific settings, while directories under nixos (e.g., nixos/common, nixos/cuda, nixos/framework) indicate structured, layered configuration for various functionalities (security, hardware, remote access, etc.).

##### Relationships and Data Flows
- Within the NixOS part, create sub-nodes for:
- Core system configuration (nixos/common),
- Desktop and hardware specifics (nixos/cuda and nixos/framework),
- Security configurations (ssh, wireguard, etc.) including remote builder settings.
- User configuration by splitting into host configurations (home/hosts) and shared modules (home/modules such as GUI and TUI). Indicate interactions such as how host-specific defaults may rely on shared modules.
- Secrets repository (.secrets) with both the NixOS and home-manager components, showing that secret keys and tokens are pulled into the system via configuration files (often referenced in the nixos and possibly home modules).

##### Architectural Patterns and Design Principles
- Modular and Declarative Configuration: Highlight that the system leverages a declarative style through NixOS and home-manager, where configurations are defined as code and orchestrated via a flake.
- Separation of Concerns: The structure divides system-level configurations (nixos/) from user-specific customizations (home/), and further splits out reusable modules (home/modules) to maintain clarity and reusability.
- Security by Isolation: The presence of a dedicated secrets directory underlines the separation and secure management of sensitive credentials.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Flake Infrastructure"
        f1["Flake File"]:::flake
        f2["Lock File"]:::flake
        f3["Flake Directory"]:::flake
    end

    subgraph "Operating System (NixOS) Configuration"
        n_common["nixos/common"]:::nixos
        n_cuda["nixos/cuda"]:::nixos
        n_framework["nixos/framework"]:::nixos
    end

    subgraph "User-Specific Configurations (home-manager)"
        h_hosts["home/hosts"]:::home
        h_modules["home/modules"]:::home
        subgraph "Modular Components"
            h_gui["GUI Module"]:::home
            h_tui["TUI Module"]:::home
        end
        h_hosts -->|"uses"| h_modules
        h_modules -->|"includes"| h_gui
        h_modules -->|"includes"| h_tui
    end

    subgraph "Secrets Management"
        s_base["Secrets Base"]:::secrets
        s_cham["Chamaeleon Secrets"]:::secrets
        s_cuda["CUDA Secrets"]:::secrets
        s_framework["Framework Secrets"]:::secrets
    end

    f1 -->|"feeds"| n_common
    f1 -->|"feeds"| h_hosts
    s_base -->|"injects"| n_common
    s_base -->|"injects"| h_hosts

    classDef flake fill:#aqua,stroke:#333,stroke-width:2px;
    classDef nixos fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef home fill:#ffffa0,stroke:#333,stroke-width:2px;
    classDef secrets fill:#ffcccb,stroke:#333,stroke-width:2px;

    click f1 "https://github.com/gaetanlepage/nix-config/blob/master/flake.nix"
    click f2 "https://github.com/gaetanlepage/nix-config/blob/master/flake.lock"
    click f3 "https://github.com/gaetanlepage/nix-config/tree/master/flake/"
    click n_common "https://github.com/gaetanlepage/nix-config/tree/master/nixos/common"
    click n_cuda "https://github.com/gaetanlepage/nix-config/tree/master/nixos/cuda"
    click n_framework "https://github.com/gaetanlepage/nix-config/tree/master/nixos/framework"
    click h_hosts "https://github.com/gaetanlepage/nix-config/tree/master/home/hosts"
    click h_modules "https://github.com/gaetanlepage/nix-config/tree/master/home/modules"
    click h_gui "https://github.com/gaetanlepage/nix-config/tree/master/home/modules/gui"
    click h_tui "https://github.com/gaetanlepage/nix-config/tree/master/home/modules/tui"
    click s_base "https://github.com/gaetanlepage/nix-config/tree/master/.secrets/"
    click s_cham "https://github.com/gaetanlepage/nix-config/tree/master/.secrets/chamaeleon"
    click s_cuda "https://github.com/gaetanlepage/nix-config/tree/master/.secrets/cuda"
    click s_framework "https://github.com/gaetanlepage/nix-config/tree/master/.secrets/framework"
```
