{ config, lib, ... }:

let
  cfg = config.stylix;
  target = cfg.targets.nixvim;

  inherit (lib) mkIf optionalAttrs;
in
{
  config = mkIf cfg.enable {
    stylix.targets.nixvim.enable = false;
    programs.nixvim.colorschemes = optionalAttrs (cfg.scheme != "generate-from-image") {
      "${cfg.scheme}".enable = !target.enable;
    };
  };
}
