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

  cfg = config.wayland.windowManager.sway.rose-pine;
  enable = cfg.enable && config.wayland.windowManager.sway.enable;

  themeName =
    if (cfg.flavor == "main")
    then "rose-pine"
    else "rose-pine-${cfg.flavor}";
  theme = "${sources.sway}/themes/${themeName}.theme";
in {
  options.wayland.windowManager.sway.rose-pine = lib.rp.mkRosePineOpt {name = "sway";};

  config = lib.mkIf enable {
    wayland.windowManager.sway.extraConfigEarly = ''
      include ${theme}
    '';
  };
}
