{
  config,
  lib,
  pkgs,
  inputs,
  ...
}:

{
  options.modules.stylix = {
    enable = lib.mkEnableOption "Whether to enable Stylix, a theme manager for NixOS";
    setupCursors = lib.mkOption {
      type = lib.types.bool;
      default = true;
      description = "Whether to setup cursors by default";
    };

    lightWallpaper = lib.mkOption {
      type = lib.types.path;
      description = "Path to light theme desktop wallpaper";
    };

    darkWallpaper = lib.mkOption {
      type = lib.types.path;
      description = "Path to dark theme desktop wallpaper";
    };
  };

  imports = [
    inputs.stylix.homeManagerModules.stylix
  ];

  config = lib.mkIf config.modules.stylix.enable {
    stylix = {
      enable = true;
      polarity = lib.mkDefault "light";

      image = lib.mkDefault config.modules.stylix.lightWallpaper;
      base16Scheme = lib.mkDefault "${pkgs.base16-schemes}/share/themes/atelier-cave.yaml";

      cursor = lib.mkIf config.modules.stylix.setupCursors {
        name = "Bibata-Modern-Classic";
        package = pkgs.bibata-cursors;
        size = 24;
      };
    };

    specialisation = {
      light.configuration.stylix = {
        polarity = "light";
        image = config.modules.stylix.lightWallpaper;
        base16Scheme = "${pkgs.base16-schemes}/share/themes/atelier-cave-light.yaml";
      };

      dark.configuration.stylix = {
        polarity = "dark";
        image = config.modules.stylix.darkWallpaper;
        base16Scheme = "${pkgs.base16-schemes}/share/themes/atelier-cave.yaml";
      };
    };
  };
}
