# ============================================================================
# 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";
#     };
#   };
{...}: {
  athenix.fleet = {
    # ========== Lab Laptops ==========
    # Creates: nix-laptop1, nix-laptop2
    # Both get hdh20267 user via overrides
    nix-laptop = {
      devices = 2;
      overrides.athenix.users.hdh20267.enable = true;
    };

    # ========== Desktop ==========
    # Creates: nix-desktop1
    nix-desktop = {
      devices = 1;
    };

    # ========== Surface Tablets (Kiosk Mode) ==========
    # Creates: nix-surface1 (custom), nix-surface2, nix-surface3 (via defaultCount)
    nix-surface = {
      defaultCount = 3;
      devices = {
        "1".athenix.sw.kioskUrl = "https://google.com";
      };
      overrides = {
        athenix.sw.kioskUrl = "https://yahoo.com";
      };
    };

    # ========== LXC Containers ==========
    # Creates: nix-builder (without lxc prefix)
    nix-lxc = {
      devices = {
        "nix-builder" = {
          # Gitea Actions self-hosted runner configuration
          athenix.sw = {
            type = [
              "headless"
              "builders"
            ];
            builders.giteaRunner = {
              enable = true;
              url = "https://git.factory.uga.edu";
              # Token file must be created manually at this path with a Gitea runner token
              # Generate in repository settings: Settings > Actions > Runners > Create new Runner
              # echo "TOKEN=YOUR_TOKEN_HERE" | sudo tee /var/lib/gitea-runner-token > /dev/null
              tokenFile = "/var/lib/gitea-runner-token";
              # Labels to identify this runner in workflows
              extraLabels = [
                "self-hosted"
                "nix-builder"
              ];
              # Runner service name
              name = "athenix";
            };
          };
        };
        "usda-dash".external = builtins.fetchGit {
          url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
          rev = "dab32f5884895cead0fae28cb7d88d17951d0c12";
          submodules = true;
        };
        "usda-dash".athenix.users.engr-ugaif.enable = true;
      };
      overrides = {
        athenix.host.useHostPrefix = false;
      };
    };

    # ========== WSL Instances ==========
    # Creates: nix-wsl-alireza
    nix-wsl = {
      devices = {
        "alireza".athenix.forUser = "sv22900";
      };
    };

    # ========== ZimaBoard Desktops ==========
    # Creates: nix-zima1, nix-zima2, nix-zima3
    nix-zima.devices = 3;

    # ========== Ephemeral/Netboot System ==========
    # Creates: nix-ephemeral1
    nix-ephemeral.devices = 1;
  };
}
