How baitinq/nixos-config works
Main Components
• Flake Entry Point:
– flake.nix & flake.lock: The root that ties together all the configurations.
• Modules:
– The “modules” directory contains encapsulated NixOS module configurations (e.g., bluetooth, doas, email, fonts, pipewire, power-save, virtualization, xorg).
• Overlays:
– The “overlays” directory holds nixpkgs overlays that patch or extend package definitions.
• Packages:
– Additional packages are defined and compiled within “packages” to extend or modify the base system.
• Secrets:
– The “secrets” folder (secured by git-crypt) includes encrypted secrets and assets like fonts and WireGuard keys.
• Dotfiles:
– The “dotfiles” directory contains user configuration files for various applications and environments (shell, emacs, tmux, sway, etc.).
• Hosts:
– This directory encapsulates host-specific configurations. It contains a “default.nix”, “configuration.nix”, "home.nix", and sub-folders for distinct hosts (like “luna” and “phobos”) to manage different system roles.
• Hardware:
– The “hardware” directory breaks down configurations based on physical hardware (laptop, chromebook, virtualbox, thinkpad) such as disk partitioning and hardware-specific Nix expressions.
• Documentation:
– Although not part of the runtime configuration, the “Documentation” folder provides installation guides and partitioning details, which is crucial for deployment.
Relationships and Interactions
– The central flake (flake.nix) includes and calls upon each component (modules, overlays, packages, secrets, etc.) to build the final configuration.
– Host-specific configurations (found under “hosts”) use the common components and import additional host-tailored settings.
– Hardware-specific directories supply low-level system settings (disk setup, partitions) that are then referenced or merged into host configurations.
– Dotfiles are deployed as part of the user’s environment, tying into both the host configuration and user-level customizations.
– Dependencies exist between the overlays and packages—for example, overlays are used to patch or extend default package definitions, which are then combined with modules.
– Encrypted secrets are imported into the configuration securely via git-crypt for handling sensitive configurations (like passwords and encryption keys).
Architectural Patterns and Important Design Principles
• Modularity:
– Every major component (modules, overlays, packages, etc.) is isolated so that configurations can be easily adapted or replaced.
• Customizability and Extensibility:
– Host and hardware configurations allow bespoke setups per environment, perfect for users needing varied deployments.
• Reproducibility:
– The entire configuration is managed via flakes, ensuring that builds are reproducible and easy to deploy.
• Security:
– Incorporation of git-crypt for managing sensitive data (secrets) and secure partitioning with BTRFS.
• Declarative Infrastructure:
– The configuration uses Nix expressions, meaning that the system’s full state is declared within the code structure.