feat: add lazy evaluation for external modules in inventory
- External modules now use 'external' field for lazy evaluation - Only fetched when building specific host (not during flake check) - Improves rebuild performance for unrelated hosts - Update examples and documentation in inventory.nix header
This commit is contained in:
174
inventory.nix
174
inventory.nix
@@ -1,72 +1,78 @@
|
||||
# ============================================================================
|
||||
# Fleet Inventory
|
||||
# ============================================================================
|
||||
# Top-level keys are ALWAYS hostname prefixes. Actual hostnames are generated
|
||||
# from the devices map or count.
|
||||
#
|
||||
# Hostname generation rules:
|
||||
# - Numeric suffixes: no dash (e.g., "nix-surface1", "nix-surface2")
|
||||
# - Non-numeric suffixes: add dash (e.g., "nix-surface-alpha", "nix-surface-beta")
|
||||
# - Set athenix.host.useHostPrefix = false to use suffix as full hostname
|
||||
#
|
||||
# Format:
|
||||
# "prefix" = {
|
||||
# type = "nix-desktop"; # Optional: defaults to prefix name
|
||||
# system = "x86_64-linux"; # Optional: default is x86_64-linux
|
||||
#
|
||||
# # Option 1: Simple count (quick syntax)
|
||||
# devices = 5; # Creates: prefix1, prefix2, ..., prefix5
|
||||
#
|
||||
# # Option 2: Explicit count
|
||||
# count = 5; # Creates: prefix1, prefix2, ..., prefix5
|
||||
#
|
||||
# # Option 3: Default count (for groups with mixed devices)
|
||||
# defaultCount = 3; # Creates default numbered hosts
|
||||
#
|
||||
# # Option 4: Named device configurations
|
||||
# devices = {
|
||||
# "1" = { ... }; # Creates: prefix1
|
||||
# "alpha" = { ... }; # Creates: prefix-alpha
|
||||
# "custom" = { # Creates: custom (no prefix)
|
||||
# athenix.host.useHostPrefix = false;
|
||||
# };
|
||||
# };
|
||||
#
|
||||
# # Common config for all devices in this group
|
||||
# overrides = {
|
||||
# athenix.users.user1.enable = true; # Applied to all devices in this group
|
||||
# # ... any other config
|
||||
# };
|
||||
# };
|
||||
#
|
||||
# Convenience options:
|
||||
# athenix.forUser = "username"; # Automatically enables user (sets athenix.users.username.enable = true)
|
||||
#
|
||||
# External modules (instead of config):
|
||||
# Device values can be a config attrset with an optional 'external' field:
|
||||
# devices."hostname" = {
|
||||
# external = builtins.fetchGit { ... }; # Lazy: only fetched when building this host
|
||||
# # ... additional config options
|
||||
# };
|
||||
# The external module will be imported and evaluated only when this specific host is built.
|
||||
#
|
||||
# Examples:
|
||||
# "lab" = { devices = 3; }; # Quick: lab1, lab2, lab3
|
||||
# "lab" = { count = 3; }; # Same as above
|
||||
# "kiosk" = {
|
||||
# defaultCount = 2; # kiosk1, kiosk2 (default)
|
||||
# devices."special" = {}; # kiosk-special (custom)
|
||||
# };
|
||||
# "laptop" = {
|
||||
# devices = 5;
|
||||
# overrides.athenix.users.student.enable = true; # All 5 laptops get this user
|
||||
# };
|
||||
# "wsl" = {
|
||||
# devices."alice".athenix.forUser = "alice123"; # Sets up for user alice123
|
||||
# };
|
||||
# "external" = {
|
||||
# devices."remote".external = builtins.fetchGit { # External module via Git (lazy)
|
||||
# url = "https://github.com/example/config";
|
||||
# rev = "e1ccd7cc3e709afe4f50b0627e1c4bde49165014";
|
||||
# };
|
||||
# };
|
||||
|
||||
{
|
||||
# ============================================================================
|
||||
# Fleet Inventory
|
||||
# ============================================================================
|
||||
# Top-level keys are ALWAYS hostname prefixes. Actual hostnames are generated
|
||||
# from the devices map or count.
|
||||
#
|
||||
# Hostname generation rules:
|
||||
# - Numeric suffixes: no dash (e.g., "nix-surface1", "nix-surface2")
|
||||
# - Non-numeric suffixes: add dash (e.g., "nix-surface-alpha", "nix-surface-beta")
|
||||
# - Set athenix.host.useHostPrefix = false to use suffix as full hostname
|
||||
#
|
||||
# Format:
|
||||
# "prefix" = {
|
||||
# type = "nix-desktop"; # Optional: defaults to prefix name
|
||||
# system = "x86_64-linux"; # Optional: default is x86_64-linux
|
||||
#
|
||||
# # Option 1: Simple count (quick syntax)
|
||||
# devices = 5; # Creates: prefix1, prefix2, ..., prefix5
|
||||
#
|
||||
# # Option 2: Explicit count
|
||||
# count = 5; # Creates: prefix1, prefix2, ..., prefix5
|
||||
#
|
||||
# # Option 3: Default count (for groups with mixed devices)
|
||||
# defaultCount = 3; # Creates default numbered hosts
|
||||
#
|
||||
# # Option 4: Named device configurations
|
||||
# devices = {
|
||||
# "1" = { ... }; # Creates: prefix1
|
||||
# "alpha" = { ... }; # Creates: prefix-alpha
|
||||
# "custom" = { # Creates: custom (no prefix)
|
||||
# athenix.host.useHostPrefix = false;
|
||||
# };
|
||||
# };
|
||||
#
|
||||
# # Common config for all devices in this group
|
||||
# overrides = {
|
||||
# athenix.users.user1.enable = true; # Applied to all devices in this group
|
||||
# # ... any other config
|
||||
# };
|
||||
# };
|
||||
#
|
||||
# Convenience options:
|
||||
# athenix.forUser = "username"; # Automatically enables user (sets athenix.users.username.enable = true)
|
||||
#
|
||||
# External modules (instead of config):
|
||||
# Device values can be either a config attrset OR a fetchGit/fetchurl call
|
||||
# that points to an external Nix module. The module will be imported and evaluated.
|
||||
#
|
||||
# Examples:
|
||||
# "lab" = { devices = 3; }; # Quick: lab1, lab2, lab3
|
||||
# "lab" = { count = 3; }; # Same as above
|
||||
# "kiosk" = {
|
||||
# defaultCount = 2; # kiosk1, kiosk2 (default)
|
||||
# devices."special" = {}; # kiosk-special (custom)
|
||||
# };
|
||||
# "laptop" = {
|
||||
# devices = 5;
|
||||
# overrides.athenix.users.student.enable = true; # All 5 laptops get this user
|
||||
# };
|
||||
# "wsl" = {
|
||||
# devices."alice".athenix.forUser = "alice123"; # Sets up for user alice123
|
||||
# };
|
||||
# "external" = {
|
||||
# devices."remote" = builtins.fetchGit { # External module via Git
|
||||
# url = "https://github.com/example/config";
|
||||
# rev = "e1ccd7cc3e709afe4f50b0627e1c4bde49165014";
|
||||
# };
|
||||
# }; # ========== Lab Laptops ==========
|
||||
# ========== Lab Laptops ==========
|
||||
# Creates: nix-laptop1, nix-laptop2
|
||||
# Both get hdh20267 user via overrides
|
||||
nix-laptop = {
|
||||
@@ -120,7 +126,7 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
"usda-dash" = builtins.fetchGit {
|
||||
"usda-dash".external = builtins.fetchGit {
|
||||
url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
||||
rev = "dab32f5884895cead0fae28cb7d88d17951d0c12";
|
||||
submodules = true;
|
||||
@@ -146,34 +152,4 @@
|
||||
# ========== Ephemeral/Netboot System ==========
|
||||
# Creates: nix-ephemeral1
|
||||
nix-ephemeral.devices = 1;
|
||||
|
||||
# ========== Example: External Module Configurations ==========
|
||||
# Uncomment to use external modules from Git repositories:
|
||||
#
|
||||
# external-systems = {
|
||||
# devices = {
|
||||
# # Option 1: fetchGit with specific revision (recommended for reproducibility)
|
||||
# "prod-server" = builtins.fetchGit {
|
||||
# url = "https://github.com/example/server-config";
|
||||
# rev = "e1ccd7cc3e709afe4f50b0627e1c4bde49165014"; # Full commit hash
|
||||
# ref = "main"; # Optional: branch/tag name
|
||||
# };
|
||||
#
|
||||
# # Option 2: fetchGit with latest from branch (less reproducible)
|
||||
# "dev-server" = builtins.fetchGit {
|
||||
# url = "https://github.com/example/server-config";
|
||||
# ref = "develop";
|
||||
# };
|
||||
#
|
||||
# # Option 3: fetchTarball for specific release
|
||||
# "test-server" = builtins.fetchTarball {
|
||||
# url = "https://github.com/example/server-config/archive/v1.0.0.tar.gz";
|
||||
# sha256 = "sha256:0000000000000000000000000000000000000000000000000000";
|
||||
# };
|
||||
#
|
||||
# # Option 4: Mix external module with local overrides
|
||||
# # Note: The external module's default.nix should export a NixOS module
|
||||
# # that accepts { inputs, ... } as parameters
|
||||
# };
|
||||
# };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user