{
  config,
  lib,
  ...
}: let
  inherit (config.rose-pine) sources;
  cfg = config.programs.bat.rose-pine;
  enable = cfg.enable && config.programs.bat.enable;
  themeName =
    if (cfg.flavor == "main")
    then "rose-pine"
    else "rose-pine-${cfg.flavor}";
in {
  options.programs.bat.rose-pine = lib.rp.mkRosePineOpt {name = "bat";};

  config = lib.mkIf enable {
    programs.bat = {
      config.theme = themeName;

      themes.${themeName} = {
        src = sources.tm-theme;
        file = "dist/themes/${themeName}.tmTheme";
      };
    };
  };
}
