# ============================================================================ # Fleet Option Definition # ============================================================================ # This module defines the athenix.fleet and athenix.hwTypes options. # Self-contained fleet management without dependencies on user configuration. { inputs, lib, ... }: let fleetDefinition = lib.mkOption { description = "Hardware types definitions for the fleet."; type = lib.types.attrsOf ( lib.types.submodule ( { name, ... }: { options = { type = lib.mkOption { type = lib.types.oneOf [ lib.types.str lib.types.listOf lib.types.str ]; default = name; description = "Type(s) of system configuration for this device."; }; system = lib.mkOption { type = lib.types.str; default = "x86_64-linux"; description = "NixOS system architecture for this hardware type."; }; devices = lib.mkOption { type = lib.types.oneOf [ lib.types.int (lib.types.attrsOf ( lib.types.submodule ( { ... }: { freeformType = lib.types.attrs; } ) )) ]; }; count = lib.mkOption { type = lib.types.int; default = 0; description = "Number of devices of this type to create."; }; defaultCount = lib.mkOption { type = lib.types.int; default = 0; description = "Default number of devices to create with default configurations and numbered hostnames."; }; overrides = lib.mkOption { type = lib.types.attrs; default = { }; description = "Overrides to apply to all devices of this type."; }; }; } ) ); }; # Forward declaration for user options (full definition in user-config.nix) # This allows users.nix to be evaluated at flake level userSubmodule = lib.types.submodule { options = { enable = lib.mkOption { type = lib.types.bool; default = false; description = "Whether this user account is enabled on this system."; }; isNormalUser = lib.mkOption { type = lib.types.bool; default = true; description = "Whether this is a normal user account (vs system user)."; }; description = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; description = "Full name or description of the user (GECOS field)."; example = "John Doe"; }; extraGroups = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; description = "Additional groups for the user (wheel, docker, etc.)."; example = [ "wheel" "networkmanager" "docker" ]; }; hashedPassword = lib.mkOption { type = lib.types.str; default = "!"; description = '' Hashed password for the user account. Generate with: mkpasswd -m sha-512 Default "!" means account is locked (SSH key only). ''; }; extraPackages = lib.mkOption { type = lib.types.listOf lib.types.package; default = [ ]; description = "Additional system packages available to this user."; example = lib.literalExpression "[ pkgs.vim pkgs.git ]"; }; excludePackages = lib.mkOption { type = lib.types.listOf lib.types.package; default = [ ]; description = "System packages to exclude for this user."; }; homePackages = lib.mkOption { type = lib.types.listOf lib.types.package; default = [ ]; description = "Packages to install in the user's home-manager profile."; example = lib.literalExpression "[ pkgs.firefox pkgs.vscode ]"; }; extraImports = lib.mkOption { type = lib.types.listOf lib.types.path; default = [ ]; description = "Additional home-manager modules to import for this user."; }; external = lib.mkOption { type = lib.types.nullOr ( lib.types.oneOf [ lib.types.path (lib.types.submodule { options = { url = lib.mkOption { type = lib.types.str; description = "Git repository URL to fetch user configuration from."; example = "https://github.com/username/dotfiles"; }; rev = lib.mkOption { type = lib.types.str; description = "Git commit hash, tag, or branch to fetch."; example = "abc123def456..."; }; submodules = lib.mkOption { type = lib.types.bool; default = false; description = "Whether to fetch Git submodules."; }; }; }) ] ); default = null; description = '' External user configuration module from Git or local path. Can be either: - A local path: /path/to/config - A Git repository: { url = "..."; rev = "..."; submodules? = false; } The Git repository is only fetched when the user is actually enabled. Should contain user.nix (user options + home-manager config) and optionally nixos.nix (system-level config). ''; example = lib.literalExpression '' { url = "https://github.com/username/dotfiles"; rev = "abc123def456789abcdef0123456789abcdef012"; submodules = false; }''; }; opensshKeys = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; description = "SSH public keys for the user (authorized_keys)."; example = [ "ssh-ed25519 AAAAC3Nza... user@host" ]; }; shell = lib.mkOption { type = lib.types.nullOr ( lib.types.enum [ "bash" "zsh" "fish" "tcsh" ] ); default = "bash"; description = "Default shell for the user."; }; editor = lib.mkOption { type = lib.types.nullOr ( lib.types.enum [ "vim" "neovim" "emacs" "nano" "code" ] ); default = "neovim"; description = "Default text editor for the user (sets EDITOR)."; }; useZshTheme = lib.mkOption { type = lib.types.bool; default = true; description = "Whether to apply the system Zsh theme (Oh My Posh)."; }; useNvimPlugins = lib.mkOption { type = lib.types.bool; default = true; description = "Whether to apply the system Neovim configuration."; }; }; }; in { options.athenix = { fleet = fleetDefinition; hwTypes = lib.mkOption { description = "Hardware types definitions for the fleet."; type = lib.types.attrs; }; users = lib.mkOption { type = lib.types.attrsOf userSubmodule; description = "User accounts configuration. Set enable=true for users that should exist on this system."; }; }; config.athenix.hwTypes = lib.mkDefault (import ../hw { inherit inputs; }); }