Unverified Commit 8f9744c8 authored by Hythera's avatar Hythera
Browse files

noriskclient-launcher-unwrapped: init at 0.6.14

parent 0c348240
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index bb58d13..c1046f8 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -100,7 +100,7 @@
         }
       }
     },
-    "active": true,
+    "active": false,
     "targets": ["app", "dmg", "deb", "appimage", "nsis"],
     "icon": [
       "icons/32x32.png",
@@ -109,7 +109,7 @@
       "icons/icon.icns",
       "icons/icon.ico"
     ],
-    "createUpdaterArtifacts": true,
+    "createUpdaterArtifacts": false,
     "fileAssociations": [
       {
         "ext": ["noriskpack"],
+34 −0
Original line number Diff line number Diff line
diff --git a/src-tauri/src/minecraft/downloads/java_download.rs b/src-tauri/src/minecraft/downloads/java_download.rs
index 25ab9b2..d1af896 100644
--- a/src-tauri/src/minecraft/downloads/java_download.rs
+++ b/src-tauri/src/minecraft/downloads/java_download.rs
@@ -9,6 +9,7 @@ use flate2::read::GzDecoder;
 use futures::future::try_join_all;
 use log::{debug, error, info};
 use reqwest;
+use std::env;
 use std::fs::File;
 use std::io::Cursor;
 use std::path::PathBuf;
@@ -526,6 +527,21 @@ impl JavaDownloadService {
             ],
         };
 
+        let target = format!("openjdk-{}", version);
+        match env::var_os("PATH") {
+            Some(paths) => {
+                for path in env::split_paths(&paths) {
+                    if let Some(path_str) = path.to_str() {
+                        if path_str.contains(&target) {
+                            debug!("Found Java binary at: {:?}", path);
+                            return Ok(path)
+                        }
+                    }
+                }
+            }
+            none => debug!("PATH is not defined"),
+        }
+
         // Try all possible paths
         for java_binary in java_binary_paths {
             debug!("Checking for Java binary at: {:?}", java_binary);
+93 −0
Original line number Diff line number Diff line
{
  cargo-tauri,
  desktop-file-utils,
  fetchFromGitHub,
  fetchYarnDeps,
  glib,
  gtk3,
  libayatana-appindicator,
  lib,
  nix-update-script,
  nodejs,
  openssl,
  pkg-config,
  rustPlatform,
  stdenv,
  webkitgtk_4_1,
  yarnConfigHook,
}:

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "noriskclient-launcher-unwrapped";
  version = "0.6.14";

  src = fetchFromGitHub {
    owner = "NoRiskClient";
    repo = "noriskclient-launcher";
    tag = "v${finalAttrs.version}";
    hash = "sha256-9UUNIS8r/695maQ2j2+Wj2L5qy55Wfs/MNhKJnwC6GI=";
  };

  yarnOfflineCache = fetchYarnDeps {
    yarnLock = "${finalAttrs.src}/yarn.lock";
    hash = "sha256-IWgP4VEyEBNsxALKGMpk8WZCIc76qcEu5K+kYqsdYkQ=";
  };

  patches = [
    # The tauri.conf.json is configured to build multiple apps. We don't want that here.
    ./disable-bundling.patch

    # Make the launcher find java from PATH, instead of downloading its own, which is not going to work on NixOS.
    ./java-from-path.patch
  ];

  postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
    substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
      --replace-fail "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
  '';

  cargoHash = "sha256-heSUEW7r9Lt26Fu68Jo/7BHW6Qmp8GrRSavukCS+ySk=";

  cargoRoot = "src-tauri";
  buildAndTestSubdir = finalAttrs.cargoRoot;

  nativeBuildInputs = [
    cargo-tauri.hook
    desktop-file-utils
    nodejs
    pkg-config
    yarnConfigHook
  ];

  buildInputs = [
    glib
    gtk3
    libayatana-appindicator
    openssl
    webkitgtk_4_1
  ];

  postInstall = ''
    desktop-file-edit \
    --set-name "NoRiskClient Launcher" \
    --set-comment "Launcher for NoRiskClient" \
    --set-key="Categories" --set-value="Game" \
    --set-key="Keywords" --set-value="nrc;minecraft;mc;" \
    $out/share/applications/NoRisk\ Launcher.desktop
  '';

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Minecraft Launcher for NoRisk Client";
    homepage = "https://norisk.gg";
    license = lib.licenses.gpl3;
    longDescription = ''
      An easy way to launch the NoRisk Client, create modpacks,
      manage content for Minecraft, and much more - written in tauri.
    '';
    maintainers = with lib.maintainers; [ hythera ];
    mainProgram = "noriskclient-launcher-v3";
    platforms = lib.platforms.linux;
  };
})