{
  config,
  pkgs,
  lib,
  theme,
  ...
}: let
  cfg = config.niko.desktop.alacritty;
in {
  options.niko.desktop.alacritty = {
    enable = lib.mkEnableOption "Alacritty terminal emulator";
    fontSize = with lib;
      mkOption {
        type = types.int;
        default =
          if pkgs.hostPlatform.isLinux
          then 9
          else 14;
        description = ''
          Font size for alacritty.
          By default on Macs the size will be larger because HiDPI and stuff
          so we want it to look pretty but still readable.
        '';
      };
  };

  config = lib.mkIf cfg.enable {
    programs.alacritty = {
      enable = true;
      settings = {
        colors = {
          primary = theme.primary;
          selection = theme.secondary;

          normal = theme.dark;
          bright = theme.bright;

          indexed_colors = [
            {
              index = 16;
              color = theme.extra.idx16;
            }
            {
              index = 17;
              color = theme.extra.idx17;
            }
          ];
        };

        font = {
          normal.family = theme.fontFamily;
          size = cfg.fontSize;
        };

        cursor.style.shape = "Beam";

        window = {
          option_as_alt = lib.mkIf pkgs.stdenv.isDarwin "Both";
          decorations =
            if pkgs.stdenv.isDarwin
            then "Buttonless"
            else "None";
        };
      };
    };
  };
}