{ pkgs, lib, config, ... }:
let cfg = config.mods.theme;
in {
  options.mods.theme = {
    enable = lib.mkEnableOption "enables stylix system theme";
    scheme = lib.mkOption {
      default = "gruvbox-dark-medium";
      description = "system color scheme";
      apply = value: "${pkgs.base16-schemes}/share/themes/${value}.yaml";
    };
    wallpaper = lib.mkOption {
      default = ./wallpaper.png;
      description = "desktop wallpaper";
    };
  };

  config = lib.mkIf cfg.enable {
    stylix.enable = true;
    stylix.autoEnable = true;
    stylix.base16Scheme = cfg.scheme;
    stylix.image = cfg.wallpaper;

    stylix.cursor = {
      name = "phinger-cursors-light";
      package = pkgs.phinger-cursors;
      size = 16;
    };

    stylix.fonts = {
      monospace = {
        package = pkgs.nerd-fonts.commit-mono;
        name = "CommitMono Nerd Font";
      };
      emoji = {
        package = pkgs.noto-fonts-emoji;
        name = "OpenMoji Color";
      };
      serif = config.stylix.fonts.monospace;
      sansSerif = config.stylix.fonts.monospace;
    };

    fonts.packages = with pkgs; [
      openmoji-color
      commit-mono
      nerd-fonts.commit-mono
    ];
  };
}
