{
  config,
  lib,
  ...
}: let
  inherit (config.rose-pine) sources;
  cfg = config.programs.btop.rose-pine;
  enable = cfg.enable && config.programs.btop.enable;

  themeFile =
    if (cfg.flavor == "main")
    then "rose-pine.theme"
    else "rose-pine-${cfg.flavor}.theme";
  themePath = "/${themeFile}";
  theme = sources.btop + themePath;
in {
  options.programs.btop.rose-pine = lib.rp.mkRosePineOpt {name = "btop";};

  config = lib.mkIf enable {
    xdg.configFile."btop/themes${themePath}".source = theme;

    programs.btop.settings.color_theme = themeFile;
  };
}
