about summary refs log tree commit diff
path: root/pkgs/by-name/at/atlauncher/package.nix
blob: a276dff1c7878e2940cb4537fc22f2de1a85949b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
  fetchFromGitHub,
  gradle,
  jre,
  lib,
  makeWrapper,
  stdenvNoCC,

  gamemodeSupport ? stdenvNoCC.hostPlatform.isLinux,
  textToSpeechSupport ? stdenvNoCC.hostPlatform.isLinux,
  additionalLibs ? [ ],

  # dependencies
  flite,
  gamemode,
  libglvnd,
  libpulseaudio,
  udev,
  xorg,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "atlauncher";
  version = "3.4.37.3";

  src = fetchFromGitHub {
    owner = "ATLauncher";
    repo = "ATLauncher";
    rev = "v${finalAttrs.version}";
    hash = "sha256-XdTbrM7FPR0o0d+p4ko48UonMsY+nLfiXj5fP2a3/zI=";
  };

  postPatch = ''
    # exclude UI tests
    sed -i "/test {/a\    exclude '**/BasicLauncherUiTest.class'" build.gradle
  '';

  nativeBuildInputs = [
    gradle
    makeWrapper
  ];

  mitmCache = gradle.fetchDeps {
    inherit (finalAttrs) pname;
    data = ./deps.json;
  };

  doCheck = true;

  gradleBuildTask = "shadowJar";

  gradleFlags = [
    "--exclude-task"
    "createExe"
  ];

  installPhase =
    let
      runtimeLibraries =
        [
          libglvnd
          libpulseaudio
          udev
          xorg.libX11
          xorg.libXcursor
          xorg.libXxf86vm
        ]
        ++ lib.optional gamemodeSupport gamemode.lib
        ++ lib.optional textToSpeechSupport flite
        ++ additionalLibs;
    in
    ''
      runHook preInstall

      mkdir -p $out/{bin,share/java}
      cp build/libs/ATLauncher-${finalAttrs.version}.jar $out/share/java/ATLauncher.jar

      makeWrapper ${lib.getExe jre} $out/bin/atlauncher \
        --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibraries}" \
        --add-flags "-jar $out/share/java/ATLauncher.jar" \
        --add-flags "--working-dir \"\''${XDG_DATA_HOME:-\$HOME/.local/share}/ATLauncher\"" \
        --add-flags "--no-launcher-update"

      runHook postInstall
    '';

  postInstall =
    let
      packagingDir = "${finalAttrs.src}/packaging/linux/_common";
    in
    ''
      install -D -m444 ${packagingDir}/atlauncher.desktop -t $out/share/applications
      install -D -m444 ${packagingDir}/atlauncher.metainfo.xml -t $out/share/metainfo
      install -D -m444 ${packagingDir}/atlauncher.png -t $out/share/pixmaps
      install -D -m444 ${packagingDir}/atlauncher.svg -t $out/share/icons/hicolor/scalable/apps
    '';

  meta = {
    changelog = "https://github.com/ATLauncher/ATLauncher/blob/v${finalAttrs.version}/CHANGELOG.md";
    description = "Simple and easy to use Minecraft launcher which contains many different modpacks for you to choose from and play";
    downloadPage = "https://atlauncher.com/downloads";
    homepage = "https://atlauncher.com";
    license = lib.licenses.gpl3;
    mainProgram = "atlauncher";
    maintainers = with lib.maintainers; [ getpsyched ];
    platforms = lib.platforms.all;
    sourceProvenance = with lib.sourceTypes; [
      fromSource
      binaryBytecode # mitm cache
    ];
  };
})