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

let
  cfg = config.local.alacritty;
in
{
  options.local.alacritty = with lib; {
    fontSize = mkOption {
      type = types.number;
      default = 11.0;
      description = "Alacritty font size";
    };
  };

  config = {
    programs.alacritty = {
      enable = true;
      settings = {
        window = {
          padding = { x = 5; y = 5; };
          decorations = "none";
          dynamic_title = true;
        };

        scrolling = {
          history = 10000;
          multiplier = 3;
        };

        font =
          let
            family = "monospace";
            mkFont = style: { inherit family style; };
          in
          {
            normal = mkFont "Regular";
            bold = mkFont "Bold";
            italic = mkFont "Italic";
            bold_italic = mkFont "Bold Italic";

            size = cfg.fontSize;
          };
      };
    };
  };
}
