{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.home.minecraft;
  gui = with config.global.gpu; enable && session;
in {
  options.home.minecraft = {
    enable = mkEnableOption "minecraft game launcher and jvm";
    user = mkOption {
      type = with types; str;
      default = "minecraft";
      description = "username which minecraft game client runs under";
    };
  };

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

    users.profiles.minecraft = mkIf (cfg.enable && cfg.user == "minecraft") {
      uid = 5801;
      description = "Minecraft";
      picture = ../picture/aux.png;
    };

    environment.persistence."/nix/persist".users.${cfg.user} = mkIf (cfg.enable && gui) {
      directories = [ ".local/share/PrismLauncher" ];
    };
  };
}
