{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.home.minecraft;
  persist = [ ".local/share/PrismLauncher" ];
in {
  options.home.minecraft = {
    enable = mkEnableOption "minecraft game launcher and jvm";
    allUsers = mkEnableOption "set up for all users";
  };

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

    users.home.persist.directories = with cfg; mkIf (enable && allUsers) persist;
    users.home.persistApp.directories = with cfg; mkIf (enable && !allUsers) persist;
  };
}
