# shun2439/nix-dotfiles architecture

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

## Overview

This repository is a configuration repository for managing dotfiles using Nix, and more specifically leveraging NixOS and Home Manager. In essence, rather than being a typical application with business logic, it’s a declarative configuration project that sets up the user environment (dotfiles) and system configuration using Nix Flakes.

##### Main Components
- Flakes & Base Definitions: Highlight the central role of flake.nix and flake.lock, which tie together all configurations.
- Home Manager Configurations: Represented under the “configs/home-manager” directory, this section covers multiple tool configurations (bash, browser, fish, git, lazygit, vim, tmux, wezterm, x, xmobar, etc.). Each subdirectory corresponds to configurations for individual applications.
- NixOS/System Configurations: Located in “configs/nixos” and also in the “systems/nixos” directory (with specific systems like “kilimanjaro” and “manyara”), this defines the system-level settings, hardware configuration, and platform-specific customizations.
- Reusable Modules: The “modules” folder (specifically modules/home-manager) provides additional, potentially reusable configuration components or abstractions.

##### Component Relationships and Interactions
- The Flake Definition (flake.nix) at the root orchestrates and aggregates the different configurations. It is the “glue” connecting home-manager configurations, NixOS configurations, and the various modules.
- Home Manager configurations provide user-level settings for the various programs. Each tool (like bash, vim, tmux, etc.) is configured independently but drawn together by the Home Manager module.
- NixOS and system-related configs define the host’s overall system behaviors. These rely on core modules, some being inherited from the “configs/nixos/core” folder.
- Modules in the “modules” directory abstract common configuration patterns and might be imported both by home-manager and system configurations.
- There is a clear separation of concerns: user-level (home-manager) vs. system-level (nixos), but both are integrated via the central flake mechanism.

##### Important Architectural Patterns and Principles
- Declarative Configuration: The entire project is defined declaratively using Nix expressions, offering reproducibility.
- Modularity and Reusability: Each configuration (e.g., for vim, tmux, etc.) is modularized, making extensions or updates isolated and maintainable.
- Flake-Based Dependency Management: Using Nix Flakes ensures that dependency versions and configurations are pinned and reproducible.

##### Relevant Technologies and Tools
- Nix/NixOS: Core technology for system configuration.
- Home Manager: Tool for managing user-specific configurations.
- Nix Flakes: The new standardized way to manage Nix-based projects.
- Specific tool configurations: Bash, Fish shell, Vim (with plugins and custom settings), Tmux, and others as noted in the file tree.

- Branch out to two primary sections: one labeled “Home Manager Config” and another “NixOS Config”.
- Under “Home Manager Config,” create child nodes for each sub-directory (e.g., bash, vim, tmux, etc.). Optionally, include a note indicating that each of these nodes represents configurations for a specific tool.
- Under “NixOS Config,” branch nodes for “Core” configurations and “Systems” (with further branches for “kilimanjaro” and “manyara”).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Flakes & Base Definitions
    subgraph "Flakes & Base Definitions"
        FN("flake.nix"):::flake
        FL("flake.lock"):::flake
    end

    %% Reusable Modules
    MOD("Reusable Modules"):::module

    %% Home Manager Configuration
    subgraph "Home Manager Config"
        HM_Root("Home Manager Config"):::home
        HM_Bash("bash"):::home
        HM_Browser("browser"):::home
        HM_Fish("fish"):::home
        HM_Git("git"):::home
        HM_Vim("vim"):::home
        HM_Tmux("tmux"):::home
        HM_Wezterm("wezterm"):::home
        HM_X("x"):::home
        HM_Xmobar("xmobar"):::home
    end

    %% NixOS Configuration
    subgraph "NixOS Config"
        Nix_Root("NixOS Config"):::nixos
        Nix_Core("Core Configs"):::nixos
        Nix_Desktop("Desktop Configs"):::nixos
        Nix_Root --> Nix_Core
        Nix_Root --> Nix_Desktop
    end

    %% NixOS Systems Specific Configuration
    subgraph "NixOS Systems"
        NS_Root("NixOS Systems"):::nixos
        NS_K("kilimanjaro"):::nixos
        NS_M("manyara"):::nixos
        NS_Root --> NS_K
        NS_Root --> NS_M
    end

    %% Relationships - vertical chain layout
    FN --> MOD
    MOD --> HM_Root
    HM_Root --> HM_Bash
    HM_Root --> HM_Browser
    HM_Root --> HM_Fish
    HM_Root --> HM_Git
    HM_Root --> HM_Vim
    HM_Root --> HM_Tmux
    HM_Root --> HM_Wezterm
    HM_Root --> HM_X
    HM_Root --> HM_Xmobar
    HM_Root --> Nix_Root
    Nix_Root --> NS_Root

    %% Click Events for Flakes & Base Definitions
    click FN "https://github.com/shun2439/nix-dotfiles/blob/main/flake.nix"
    click FL "https://github.com/shun2439/nix-dotfiles/blob/main/flake.lock"

    %% Click Event for Modules
    click MOD "https://github.com/shun2439/nix-dotfiles/tree/main/modules/home-manager"

    %% Click Events for Home Manager Config Root and its tool configurations
    click HM_Root "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager"
    click HM_Bash "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/bash"
    click HM_Browser "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/browser"
    click HM_Fish "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/fish"
    click HM_Git "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/git"
    click HM_Vim "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/vim"
    click HM_Tmux "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/tmux"
    click HM_Wezterm "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/wezterm"
    click HM_X "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/x"
    click HM_Xmobar "https://github.com/shun2439/nix-dotfiles/tree/main/configs/home-manager/xmobar"

    %% Click Events for NixOS Config nodes
    click Nix_Root "https://github.com/shun2439/nix-dotfiles/tree/main/configs/nixos"
    click Nix_Core "https://github.com/shun2439/nix-dotfiles/tree/main/configs/nixos/core"
    click Nix_Desktop "https://github.com/shun2439/nix-dotfiles/tree/main/configs/nixos/desktop"

    %% Click Events for NixOS Systems
    click NS_Root "https://github.com/shun2439/nix-dotfiles/tree/main/systems/nixos"
    click NS_K "https://github.com/shun2439/nix-dotfiles/tree/main/systems/nixos/kilimanjaro"
    click NS_M "https://github.com/shun2439/nix-dotfiles/tree/main/systems/nixos/manyara"

    %% Class Definitions for Colors
    classDef flake fill:#f88,stroke:#000,stroke-width:2px;
    classDef module fill:#f8f,stroke:#000,stroke-width:2px;
    classDef home fill:#8f8,stroke:#000,stroke-width:2px;
    classDef nixos fill:#88f,stroke:#000,stroke-width:2px;
```
