# ============================================================================
# Common Host Module
# ============================================================================
# This module contains all the common configuration shared by all host types.
# It is automatically imported by the fleet generator for every host.

{
  inputs,
  config,
  lib,
  ...
}:
{
  imports = [
    ./fs.nix
    ./boot.nix
    ./user-config.nix
    ./fleet-option.nix
    ../sw
  ];

  options.athenix = {
    forUser = lib.mkOption {
      type = lib.types.nullOr lib.types.str;
      default = null;
      description = ''
        Convenience option to configure a host for a specific user.
        Automatically enables the user (sets athenix.users.username.enable = true).
        Value should be a username from athenix.users.accounts.
      '';
    };
    host.useHostPrefix = lib.mkOption {
      type = lib.types.bool;
      default = true;
      description = "Whether to prepend the host prefix to the hostname (used in inventory and hosts/default.nix).";
    };
  };

  config = lib.mkMerge [
    (lib.mkIf (config.athenix.forUser != null) {
      athenix.users.${config.athenix.forUser}.enable = true;
    })
    {
      system.stateVersion = "25.11";
      nix.settings.experimental-features = [
        "nix-command"
        "flakes"
      ];
    }
  ];
}
