{
  config,
  lib,
  ...
}: let
  inherit (config.rose-pine) sources;

  cfg = config.services.polybar.rose-pine;
  enable = cfg.enable && config.services.polybar.enable;

  themeName =
    if (cfg.flavor == "main")
    then "rose-pine"
    else "rose-pine-${cfg.flavor}";
in {
  options.services.polybar.rose-pine = lib.rp.mkRosePineOpt {name = "polybar";};

  config.services.polybar.extraConfig = lib.mkIf enable (
    builtins.readFile "${sources.polybar}/schemes/${themeName}.ini"
  );
}
