How wendingtuo/nix-config works
Project Type & Purpose
• This is an “Infrastructure‑as‑Code” repository using Nix flakes to manage both NixOS system configurations (in hosts/…) and user (home‑manager) configurations (in modules/home‑manager/…).
• Purpose: Provide a single flake entrypoint (flake.nix) that composes OS modules, home modules, and overlays to produce reproducible builds for a host (nixvm) and a user (blake).
File Structure
• Top Level:
• flake.nix / flake.lock – root flake definition and lockfile
• hosts/nixvm/ – NixOS machine‑specific module + hardware config
• modules/ – reusable NixOS and home‑manager module sets
• overlays/ – package overlays or customizations
• result – symlink to the last flake build
• Modules split:
• modules/nixos/common + desktop + services
• modules/home-manager/common + desktop + programs
README
• The README describes clone/build commands:
• nixos-rebuild switch --impure --flake .#hostname
• home-manager switch --flake .#user@hostname
• Manual steps are outside Nix (WireGuard, Nextcloud login, etc.), but the repo governs software installation & GNOME/Hyprland theming, Tailscale, Syncthing, etc.
Main Components
a. Flake Entrypoint
• flake.nix (defines inputs: nixpkgs, home‑manager, modules, overlays)
• flake.lock
b. NixOS Configuration Layer
• Hosts directory → hosts/nixvm/default.nix + hardware-configuration.nix
• Aggregates modules from modules/nixos/*
c. Home‑Manager Configuration Layer
• User directory under flake outputs → references modules/home-manager/*
d. Overlays
• Custom nixpkgs overlays in overlays/default.nix
e. Build & Activation Tools
• nixos-rebuild CLI → systemd activation on host
• home-manager CLI → user profiles
f. External Systems
• GitHub (source of flake)
• Nix package registry (nixpkgs)
• Target VM/hardware
• Optional: Wireguard/NetworkManager, Nextcloud, Firefox sync, Syncthing – shown as post‑activation services.
Relationships & Data Flow
• Flake inputs (nixpkgs, overlays, modules) → evaluated by Nix daemon → produces two outputs: “nixosConfigurations.nixvm.config” and “homeConfigurations.blake@…”.
• nixos-rebuild switch reads the flake’s nixosConfiguration output → builds system closure → pushes config to /etc/nixos → systemd switch.
• home-manager switch reads the flake’s homeConfigurations → builds user profile → symlinks ~/.config & activates services.
Architectural Patterns & Principles
• Functional, declarative infrastructure.
• Composition via flakes: single source of truth, modular design.
• Separation of concerns: OS vs user config.
• Reusability: common modules for desktop, services, programs.
Final Checklist
[ ] Flake entrypoint block
[ ] Inputs grouping (nixpkgs, overlays, modules)
[ ] Outputs grouping (nixosConfigurations, homeConfigurations)
[ ] External service nodes