about summary refs log tree commit diff
path: root/packages/ultimmc.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-08-12 22:53:53 +0300
committerAzat Bahawi <azat@bahawi.net>2022-08-12 22:53:53 +0300
commit61b94f0dd06cac0f7dcd38cce80f2a7ab8376098 (patch)
treeb703a9fe11eae6c4cae4e4682f02caf0caa171d0 /packages/ultimmc.nix
2022-08-12
Diffstat (limited to '')
-rw-r--r--packages/ultimmc.nix63
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/ultimmc.nix b/packages/ultimmc.nix
new file mode 100644
index 0000000..e90d5bd
--- /dev/null
+++ b/packages/ultimmc.nix
@@ -0,0 +1,63 @@
+{
+  cmake,
+  fetchFromGitHub,
+  jdk,
+  makeDesktopItem,
+  qtbase,
+  stdenv,
+  wrapQtAppsHook,
+  zlib,
+}:
+stdenv.mkDerivation rec {
+  pname = "UltimMC";
+  version = "unstable-2022-06-09";
+
+  src = fetchFromGitHub {
+    owner = "UltimMC";
+    repo = "Launcher";
+    rev = "b7c9b27ed6fb047da7fab5e4cee99b298b9e9811";
+    hash = "sha256-xmkflvtOSLMTuzAKovgOLjgpbR8j53bkGV3QZRsQItw=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [cmake jdk 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"';
+  '';
+
+  cmakeFlags = ["-DCMAKE_BUILD_TYPE=Release"];
+
+  desktopItem = makeDesktopItem {
+    name = pname;
+    exec = pname;
+    icon = pname;
+    desktopName = pname;
+    genericName = "Custom Minecraft launcher";
+    categories = ["Game"];
+  };
+
+  dontWrapQtApps = true;
+
+  postInstall = ''
+    rm $out/${pname}
+
+    wrapProgram $out/bin/${pname} \
+      --add-flags "--dir \''${XDG_DATA_HOME:-~/.local/share}/${pname}" \
+      "''${qtWrapperArgs[@]}"
+
+    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
+  '';
+}

Consider giving Nix/NixOS a try! <3