How manas73/nix-config works
Main Components
• Entry Point: At the heart is flake.nix – the primary entry point for the entire configuration.
• Hosts & Machine-Specific Configurations: The hosts/ directory contains configurations for individual machines (e.g., “alfred,” “manass-KY4RYYHFF6”), which are applied by the sync scripts.
• System Modules: The system_modules/ directory houses reusable Nix modules dedicated to system-level functionalities like the desktop manager (with submodules for Plasma6 or SDDM and themes), font, keyring, shell, and window manager (supporting various window managers like Hyprland, i3, etc.). These encapsulate the configuration and settings that affect the operating system overall.
• User Modules: The user_modules/ directory handles Home Manager configurations for individual software groups such as browsers, communication (e.g., Slack, Zoom), development tools (e.g., DataGrip, Postman), office suites, terminals, and utility applications.
• Darwin Modules: Special configurations for macOS (in darwin_modules/) are segregated similarly into categories (e.g., browsers, communication, development, office, terminal, utility).
• User-Specific Configurations: The users/ directory contains personal configurations and further customizations for individual accounts.
Relationships & Interactions
• The flake.nix acts as the orchestrator, referencing system_modules, user_modules, hosts, and darwin_modules as needed based on the target deployment (NixOS vs. Darwin).
• The sync scripts (sync-system.sh, sync-user.sh, sync.sh, and sync-darwin.sh) drive the deployment process by applying configurations from the corresponding modules to the target machine.
• The hosts/ configurations override or add machine-specific nuances to the base settings provided by the modules.
• There is a clear separation between system-level configurations (system_modules) and user-level configurations (user_modules), which are then applied via Home Manager on NixOS or similar tools on macOS.
Architectural Patterns / Design Principles
• Modular Design: Each configuration aspect (e.g., browsers, development tools, window managers) is encapsulated in its own module, making it easy to extend or override.
• Separation of Concerns: Different directories are solely dedicated to system modules, user modules, and host configurations. There’s also a dedicated set of modules for macOS (“darwin_modules”), which recognizes platform-specific needs.
• Reusability and Extensibility: The create_module.sh script hints at a workflow for easily adding new configuration modules. This reinforces the architecture’s modular and extensible nature.
• Declarative Infrastructure: Through Nix Flakes and declarative configuration files, the project gives a clear mapping between desired system states and their corresponding module configurations.
Relevant Technologies and Frameworks
• NixOS & Nix Flakes: The entire configuration is managed via Nix’s declarative package management and configuration system.
• Home Manager: For applying user-specific configurations.
• Nix-Darwin: For handling macOS-specific configurations.
• nix-sops (via secrets.yaml): For safely managing sensitive data.
• Shell scripts (sync.sh variants): For deployment orchestration.