{ config, lib, pkgs, ... }:

{

  imports = [
    ./programs
    ./home.nix
    ./system.nix
  ];

  options = {

    # Primary user of the system
    user = lib.mkOption {
      type = lib.types.str;
      description = "Primary user of the system";
    };
    fullName = lib.mkOption {
      type = lib.types.str;
      description = "Human readable name of the user";
    };
    homePath = lib.mkOption {
      type = lib.types.str;
      description = "Home directory path of the user";
      default = "/home/${config.user}";
    };
    email = lib.mkOption {
      type = lib.types.str;
      description = "Primary email of the user";
    };

    # Toggable components
    desktop = {
      enable = lib.mkEnableOption {
        description = "Enable the gui.";
        default = false;
      };
    };
    system = {
      enable = lib.mkEnableOption {
        description = "Enable system services.";
        default = false;
      };
    };

    # Monitor
    monitor = {
      name = lib.mkOption {
        type = lib.types.str;
        description = "Name of the primary monitor.";
        default = "";
      };
      scale = lib.mkOption {
        type = lib.types.float;
        description = "Scale of the primary monitor.";
        default = 1.0;
      };
    };

    # Theme of the system
    theme = {
      colors = lib.mkOption {
        type = lib.types.attrs;
        description = "base16 color scheme";
        default = (import ./themes).catppuccin.mocha;
      };

      accentColor = lib.mkOption {
        type = lib.types.str;
        description = "Theme accent color.";
        default = config.theme.colors.base0D;
      };

      opacity = lib.mkOption {
        type = lib.types.float;
        description = "Window opacity.";
        default = 1.0;
      };

      font = lib.mkOption {
        type = lib.types.str;
        description = "Theme primary font.";
        default = "JetBrains Mono";
      };

      fontSize = lib.mkOption {
        type = lib.types.int;
        description = "Theme primary font size.";
        default = 14;
      };

      headerFont = lib.mkOption {
        type = lib.types.str;
        description = "Theme header font.";
        default = "JetBrains Mono ExtraBold";
      };

      monospaceFont = lib.mkOption {
        type = lib.types.str;
        description = "Theme monospace font.";
        default = "monospace";
      };

      iconFont = lib.mkOption {
        type = lib.types.str;
        description = "Theme icon font.";
        default = "Font Awesome 6 Pro";
      };

      borderWidth = lib.mkOption {
        type = lib.types.int;
        description = "Theme border width";
        default = 3;
      };

      outerRadius = lib.mkOption {
        type = lib.types.int;
        description = "Theme outer border radius.";
        default = 5;
      };

      innerRadius = lib.mkOption {
        type = lib.types.int;
        description = "Theme inner border radius.";
        default = 2;
      };

      outerGap = lib.mkOption {
        type = lib.types.int;
        description = "Theme outer gap/spacing.";
        default = 10;
      };

      innerGap = lib.mkOption {
        type = lib.types.int;
        description = "Theme inner gap/spacing.";
        default = 3;
      };
    };

    wallpaper = lib.mkOption {
      type = lib.types.str;
      description = "Path to wallpaper image";
      default = "";
    };

    avatar = lib.mkOption {
      type = lib.types.str;
      description = "Path to avatar image";
      default = "";
    };
  };

  config = {

    # use system packages in home manager
    home-manager.useGlobalPkgs = true;

    # install user packages to /etc/profiles and not home directory
    home-manager.useUserPackages = true;

    # allow flakes
    nix.settings.experimental-features = [ "nix-command" "flakes" ];

    # allow unfree packages
    nixpkgs.config.allowUnfree = true;

    # set state version
    home-manager.users.${config.user}.home.stateVersion = "25.05";
    home-manager.users.root.home.stateVersion = "25.05";
    system.stateVersion = "25.05";

  };

}