diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index c6a0cb6..ddf2e70 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -26,8 +26,9 @@ This is a **NixOS system configuration repository** that uses: - **`flake.nix`**: Entry point - inputs and outputs only - **`inventory.nix`**: Fleet definitions - host configurations - **`users.nix`**: User account definitions -- **`hosts/`**: Host generation logic and hardware types -- **`sw/`**: Software configurations organized by system type +- **`variants/`**: Hardware type modules (desktop, laptop, surface, lxc, wsl, etc.) +- **`glue/`**: Fleet generation logic and common system configuration +- **`sw/`**: Software configurations by system type - **`installer/`**: Build artifact generation (ISO, LXC, etc.) - **`templates/`**: Templates for external configurations diff --git a/README.md b/README.md index 0d1dc3b..8e2d0e7 100644 --- a/README.md +++ b/README.md @@ -54,18 +54,21 @@ users.nix # User account definitions flake.lock # Locked dependency versions -hosts/ # Host generation logic -├── default.nix # Main host generator +variants/ # Hardware type modules (exportable as nixosModules) +├── default.nix # Auto-exports all variant types +├── nix-desktop.nix # Desktop workstations +├── nix-laptop.nix # Laptop systems +├── nix-surface.nix # Surface Pro tablets +├── nix-lxc.nix # LXC containers +├── nix-wsl.nix # WSL instances +├── nix-zima.nix # ZimaBoard systems +└── nix-ephemeral.nix # Diskless/netboot systems + +glue/ # Fleet generation and common configuration +├── fleet.nix # Processes inventory.nix to generate all hosts +├── common.nix # Common NixOS configuration (all hosts) ├── boot.nix # Boot and filesystem configuration -├── common.nix # Common system configuration -├── user-config.nix # User configuration integration -└── types/ # Hardware type modules - ├── nix-desktop.nix - ├── nix-laptop.nix - ├── nix-surface.nix - ├── nix-lxc.nix - ├── nix-wsl.nix - └── nix-ephemeral.nix +└── user-config.nix # User account and home-manager integration sw/ # Software configurations by system type ├── default.nix # Software module entry point diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 4ad8558..316b3ae 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -87,7 +87,7 @@ athenix.users.newuser = { }; ``` -2. Enable on hosts in `inventory.nix`: +2. Enable on fleet in `inventory.nix`: ```nix nix-laptop = { @@ -294,7 +294,7 @@ For system config: ```nix # inventory.nix nix-lxc = { - devices."server" = builtins.fetchGit { + devices."server".external = builtins.fetchGit { url = "https://git.factory.uga.edu/org/server-config"; rev = "abc123..."; }; diff --git a/docs/EXTERNAL_MODULES.md b/docs/EXTERNAL_MODULES.md index 48203e1..a94dfef 100644 --- a/docs/EXTERNAL_MODULES.md +++ b/docs/EXTERNAL_MODULES.md @@ -28,26 +28,42 @@ External system modules provide host-specific NixOS configurations. ### Usage -In `inventory.nix`, reference an external module as a device: +In `inventory.nix`, reference an external module using the `external` field: ```nix nix-lxc = { devices = { - # Inline configuration + # Inline configuration (traditional method) "local-server" = { athenix.sw.type = "headless"; services.nginx.enable = true; }; - # External module - "remote-server" = builtins.fetchGit { + # External module (lazy evaluation - fetched only when building this host) + "remote-server".external = builtins.fetchGit { url = "https://git.factory.uga.edu/org/server-config"; rev = "abc123def456..."; # Must pin to specific commit }; + + # External module with additional local config + "mixed-server" = { + external = builtins.fetchGit { + url = "https://git.factory.uga.edu/org/server-config"; + rev = "abc123def456..."; + }; + # Additional local overrides + athenix.users.admin.enable = true; + services.openssh.permitRootLogin = "no"; + }; }; }; ``` +**Key Features:** +- **Lazy Evaluation**: External modules are only fetched when building the specific host +- **Efficient Rebuilds**: Other hosts can be rebuilt without fetching unrelated external modules +- **Submodule Support**: Works with Git submodules without affecting other hosts + ### Repository Structure ``` @@ -99,8 +115,8 @@ server-config/ When a host is built, modules load in this order: -1. Hardware type module (from `hosts/types/nix-*.nix`) -2. Host common configuration (from `hosts/common.nix`) +1. Hardware type module (from `variants/nix-*.nix`) +2. Common system configuration (from `glue/common.nix`) 3. Software type module (from `sw/{type}/`) 4. User NixOS modules (from `users.nix` - `nixos.nix` files) 5. Device-specific overrides (from `inventory.nix`) diff --git a/docs/INVENTORY.md b/docs/INVENTORY.md index f83b5e8..20eaacd 100644 --- a/docs/INVENTORY.md +++ b/docs/INVENTORY.md @@ -123,11 +123,11 @@ nix-surface = { ### Method 4: External Module -Reference a Git repository instead of inline configuration: +Reference a Git repository using the `external` field (lazy evaluation): ```nix nix-lxc = { - devices."builder" = builtins.fetchGit { + devices."builder".external = builtins.fetchGit { url = "https://git.factory.uga.edu/org/builder-config"; rev = "abc123..."; }; diff --git a/installer/PROXMOX_LXC.md b/installer/PROXMOX_LXC.md index f573405..057e3c9 100644 --- a/installer/PROXMOX_LXC.md +++ b/installer/PROXMOX_LXC.md @@ -46,7 +46,7 @@ Add the host to `inventory.nix` with the `nix-lxc` type or ensure it has the app } ``` -Your host type configuration (`hosts/types/nix-lxc.nix`) should include: +Your host type configuration (`variants/nix-lxc.nix`) should include: ```nix {