{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.home.jetbrains;
in {
  options.home.jetbrains = {
    enable = mkEnableOption "jetbrains text editor";
    idea = mkEnableOption "intellij idea";
    clion = mkEnableOption "clion ide";
    goland = mkEnableOption "goland ide" // { default = true; };
  };

  config = {
    users.homeModules = [
      # this module passes jetbrains configuration to home-manager
      { passthrough.jetbrains = cfg; }
    ];

    users.home.persist.directories = mkIf cfg.enable [
      "go"
      ".java/.userPrefs"
      ".config/JetBrains"
      ".local/share/JetBrains"
    ];
  };
}
