about summary refs log tree commit diff
path: root/packages/ultimmc.nix
blob: 0259a7aee38c56a81ba5ae9cf9ba9ec7f3e599f1 (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
{
  cmake,
  fetchFromGitHub,
  jdk,
  makeDesktopItem,
  ninja,
  qtbase,
  stdenv,
  wrapQtAppsHook,
  zlib,
}:
stdenv.mkDerivation rec {
  pname = "UltimMC";
  version = "git";

  src = fetchFromGitHub {
    owner = "UltimMC";
    repo = "Launcher";
    rev = "a522ec3ad4602de1f457a25bce98ef912a29d7d6";
    fetchSubmodules = true;
    hash = "sha256-+UgBblyEx0cKH8UMBOPtjhQLv2YUKj91UokQWKCEPbY=";
  };

  nativeBuildInputs = [cmake jdk ninja wrapQtAppsHook];

  buildInputs = [qtbase zlib];

  postPatch = ''
    substituteInPlace CMakeLists.txt \
      --replace 'LIBRARY_DEST_DIR "bin"' 'LIBRARY_DEST_DIR "lib"' \
      --replace 'JARS_DEST_DIR "bin/jars"' 'JARS_DEST_DIR "share/${pname}/jar"'

    substituteInPlace launcher/Application.cpp \
      --replace '"jars"' '"../share/${pname}/jar"';
  '';

  desktopItem = makeDesktopItem {
    name = pname;
    exec = pname;
    icon = pname;
    desktopName = pname;
    genericName = "Custom Minecraft launcher";
    categories = ["Game"];
  };

  dontWrapQtApps = true;

  postInstall = ''
    rm $out/${pname}

    install -Dm644 \
      ${desktopItem}/share/applications/${pname}.desktop \
      $out/share/applications/${pname}.desktop
    install -Dm644 \
      $src/notsecrets/logo.svg \
      $out/share/icons/hicolor/scalable/apps/${pname}.svg
  '';

  postFixup = ''
    wrapProgram $out/bin/${pname} \
      --add-flags "--dir \''${XDG_DATA_HOME:-~/.local/share}/${pname}" \
      "''${qtWrapperArgs[@]}"
  '';
}

Consider giving Nix/NixOS a try! <3