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

with lib;
let
  cfg = config.my.programs.prismlauncher;

  prismlauncher = pkgs.runCommandNoCC "prismlauncher"
    {
      nativeBuildInputs = [ pkgs.makeWrapper ];
    } ''
    makeWrapper ${lib.getExe pkgs.prismlauncher} $out/bin/prismlauncher \
      --set QT_STYLE_OVERRIDE "" \
      --set QT_QPA_PLATFORMTHEME "gtk3"
  '';
in
{
  options.my.programs.prismlauncher.enable = mkEnableOption "prismlauncher";

  config = mkIf cfg.enable {
    environment.persistence."/persist".users.moritz.directories = [
      ".local/share/PrismLauncher/"
    ];

    users.users.moritz.packages = [ prismlauncher ];
  };
}
