How danielkosgei/nix-config works
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.