Unverified Commit 549201bc authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

noriskclient-launcher: init at 0.6.14 (#464650)

parents 36166dee 8784eec7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10851,6 +10851,12 @@
    githubId = 2090758;
    keys = [ { fingerprint = "24F4 1925 28C4 8797 E539  F247 DB2D 93D1 BFAA A6EA"; } ];
  };
  hythera = {
    name = "Hythera";
    github = "Hythera";
    githubId = 87016780;
    matrix = "@hythera:matrix.org";
  };
  hyzual = {
    email = "hyzual@gmail.com";
    github = "Hyzual";
+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);
+92 −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,
  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 = ''
    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.gpl3Only;
    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;
  };
})
+101 −0
Original line number Diff line number Diff line
{
  addDriverRunpath,
  alsa-lib,
  flite,
  glib,
  glib-networking,
  gsettings-desktop-schemas,
  jdk17,
  jdk21,
  jdk8,
  jdks ? [
    jdk8
    jdk17
    jdk21
  ],
  lib,
  libGL,
  libjack2,
  libpulseaudio,
  libX11,
  libXcursor,
  libXext,
  libXrandr,
  libXxf86vm,
  noriskclient-launcher-unwrapped,
  pipewire,
  stdenv,
  symlinkJoin,
  udev,
  wrapGAppsHook4,
}:

symlinkJoin {
  pname = "noriskclient-launcher";
  inherit (noriskclient-launcher-unwrapped) version;

  paths = [ noriskclient-launcher-unwrapped ];

  strictDeps = true;

  nativeBuildInputs = [
    glib
    wrapGAppsHook4
  ];

  buildInputs = [
    glib-networking
    gsettings-desktop-schemas
  ];

  runtimeDependencies = lib.optionalString stdenv.hostPlatform.isLinux (
    lib.makeLibraryPath [
      addDriverRunpath.driverLink

      # glfw
      libGL
      libX11
      libXcursor
      libXext
      libXrandr
      libXxf86vm

      # narrator support
      flite

      # openal
      alsa-lib
      libjack2
      libpulseaudio
      pipewire

      # oshi
      udev
    ]
  );

  postBuild = ''
    gappsWrapperArgs+=(
      --prefix PATH : ${lib.makeSearchPath "bin/java" jdks}
      ${lib.optionalString stdenv.hostPlatform.isLinux ''
        --set LD_LIBRARY_PATH $runtimeDependencies
      ''}
    )

    glibPostInstallHook
    gappsWrapperArgsHook
    wrapGAppsHook
  '';

  meta = {
    inherit (noriskclient-launcher-unwrapped.meta)
      description
      homepage
      license
      longDescription
      maintainers
      mainProgram
      platforms
      ;
  };
}