Commit 6859773d authored by Aidan Gauland's avatar Aidan Gauland
Browse files

heroic: restore

@iedane is taking over as sole maintainer.
parent c7502377
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  gitUpdater,
  fetchFromGitHub,
  cmake,
  pkgsCross,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "heroic-epic-integration";
  version = "0.3";

  src = fetchFromGitHub {
    owner = "Etaash-mathamsetty";
    repo = "heroic-epic-integration";
    tag = "v${finalAttrs.version}";
    hash = "sha256-Zn0MsaQd8Ro6eu8IQkMcLNGLVTUukwajkn8PRLfB+Yw=";
  };

  nativeBuildInputs = [
    cmake
    pkgsCross.mingwW64.buildPackages.gcc
  ];

  cmakeFlags = [ (lib.cmakeFeature "CMAKE_TOOLCHAIN_FILE" "../windows.cmake") ];

  installPhase = ''
    runHook preInstall

    mkdir $out
    cp heroic-epic-integration.exe $out/EpicGamesLauncher.exe

    runHook postInstall
  '';

  meta = {
    description = "Wrapper process for games launched through Heroic Games Launcher";
    longDescription = ''
      This is a Windows executable that pretends to be EpicGamesLauncher.exe for
      games that expect it to be their parent process.
    '';
    homepage = "https://github.com/Etaash-mathamsetty/heroic-epic-integration";
    changelog = "https://github.com/Etaash-mathamsetty/heroic-epic-integration/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ iedame ];
  };

  passthru.updateScript = gitUpdater { };
})
+13 −0
Original line number Diff line number Diff line
diff --git a/src/backend/shortcuts/nonesteamgame/nonesteamgame.ts b/src/backend/shortcuts/nonesteamgame/nonesteamgame.ts
index ebef6aa4..c8bd853d 100644
--- a/src/backend/shortcuts/nonesteamgame/nonesteamgame.ts
+++ b/src/backend/shortcuts/nonesteamgame/nonesteamgame.ts
@@ -252,7 +252,7 @@ async function addNonSteamGame(props: {
     // add new Entry
     const newEntry = {} as ShortcutEntry
     newEntry.AppName = props.gameInfo.title
-    newEntry.Exe = `"${app.getPath('exe')}"`
+    newEntry.Exe = `"heroic"`
     newEntry.StartDir = `"${process.cwd()}"`
 
     if (isFlatpak) {
+45 −0
Original line number Diff line number Diff line
{
  lib,
  gitUpdater,
  fetchFromGitHub,
  python3Packages,
}:
let
  version = "0.20.37";
in
python3Packages.buildPythonApplication {
  pname = "legendary-heroic";
  inherit version;
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "Heroic-Games-Launcher";
    repo = "legendary";
    rev = version;
    sha256 = "sha256-mOys7lOPrrzBUBMIM/JvKygFQ/qIGD68BDNigk5BCIo=";
  };

  build-system = with python3Packages; [
    setuptools
  ];

  dependencies = with python3Packages; [
    requests
    filelock
  ];

  pythonImportsCheck = [ "legendary" ];

  meta = with lib; {
    description = "Free and open-source Epic Games Launcher alternative";
    longDescription = ''
      This is the Heroic Games Launcher's fork of legendary.
    '';
    homepage = "https://github.com/Heroic-Games-Launcher/legendary";
    license = licenses.gpl3;
    maintainers = with maintainers; [ iedame ];
    mainProgram = "legendary";
  };

  passthru.updateScript = gitUpdater { };
}
+135 −0
Original line number Diff line number Diff line
{
  lib,
  callPackage,
  stdenv,
  fetchFromGitHub,
  # Pinned, because our FODs are not guaranteed to be stable between major versions.
  pnpm_10,
  nodejs,
  python3,
  makeWrapper,
  # Electron updates frequently break Heroic, so pin same version as upstream, or newest non-EOL.
  electron_36,
  vulkan-helper,
  gogdl,
  nile,
  comet-gog_heroic,
  umu-launcher,
}:

let
  legendary = callPackage ./legendary.nix { };
  epic-integration = callPackage ./epic-integration.nix { };
  comet-gog = comet-gog_heroic;
  electron = electron_36;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "heroic-unwrapped";
  version = "2.18.1";

  src = fetchFromGitHub {
    owner = "Heroic-Games-Launcher";
    repo = "HeroicGamesLauncher";
    tag = "v${finalAttrs.version}";
    hash = "sha256-x792VA4PZleqUUgarh59JxJVXrvT95/rINYk8t9i3X0=";
  };

  pnpmDeps = pnpm_10.fetchDeps {
    inherit (finalAttrs) pname version src;
    fetcherVersion = 1;
    hash = "sha256-F8H0eYltIJ0S8AX+2S3cR+v8dvePw09VWToVOLM8qII=";
  };

  nativeBuildInputs = [
    nodejs
    pnpm_10.configHook
    python3
    makeWrapper
  ];

  patches = [
    # Make Heroic create Steam shortcuts (to non-steam games) with the correct path to heroic.
    ./fix-non-steam-shortcuts.patch
    # Fixes incorrect path to GalaxyCommunication.exe
    ./pr-4885.patch
  ];

  env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";

  buildPhase = ''
    runHook preBuild

    # set nodedir to prevent node-gyp from downloading headers
    export npm_config_nodedir=${electron.headers}

    pnpm --offline electron-vite build
    pnpm --offline electron-builder \
      --linux \
      --dir \
      -c.asarUnpack="**/*.node" \
      -c.electronDist=${electron.dist} \
      -c.electronVersion=${electron.version}

    runHook postBuild
  '';

  # --disable-gpu-compositing is to work around upstream bug
  # https://github.com/electron/electron/issues/32317
  installPhase = ''
    runHook preInstall

    mkdir -p "$out/opt/heroic"
    cp -r dist/linux-unpacked/resources "$out/opt/heroic"

    cp -r public "$out/opt/heroic/resources/app.asar.unpacked/build"
    rm -rf "$out/opt/heroic/resources/app.asar.unpacked/build/bin"
    mkdir -p \
      "$out/opt/heroic/resources/app.asar.unpacked/build/bin/x64/linux" \
      "$out/opt/heroic/resources/app.asar.unpacked/build/bin/x64/win32"
    ln -s \
      "${lib.getExe gogdl}" \
      "${lib.getExe legendary}" \
      "${lib.getExe nile}" \
      "${lib.getExe comet-gog}" \
      "${lib.getExe vulkan-helper}" \
      "$out/opt/heroic/resources/app.asar.unpacked/build/bin/x64/linux"
    # Don't symlink these so we don't confuse Windows applications under Wine/Proton.
    cp \
      "${comet-gog.dummy-service}/GalaxyCommunication.exe" \
      "${epic-integration}/EpicGamesLauncher.exe" \
      "$out/opt/heroic/resources/app.asar.unpacked/build/bin/x64/win32"

    makeWrapper "${electron}/bin/electron" "$out/bin/heroic" \
      --inherit-argv0 \
      --set ELECTRON_FORCE_IS_PACKAGED 1 \
      --suffix PATH ":" "${umu-launcher}/bin" \
      --add-flags --disable-gpu-compositing \
      --add-flags $out/opt/heroic/resources/app.asar \
      --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"

    install -D "flatpak/com.heroicgameslauncher.hgl.desktop" "$out/share/applications/com.heroicgameslauncher.hgl.desktop"
    install -D "src/frontend/assets/heroic-icon.svg" "$out/share/icons/hicolor/scalable/apps/com.heroicgameslauncher.hgl.svg"
    substituteInPlace "$out/share/applications/com.heroicgameslauncher.hgl.desktop" \
      --replace-fail "Exec=heroic-run --ozone-platform-hint=auto" "Exec=heroic"

    runHook postInstall
  '';

  passthru = {
    inherit epic-integration legendary;
  };

  meta = with lib; {
    description = "Native GOG, Epic, and Amazon Games Launcher for Linux, Windows and Mac";
    homepage = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher";
    changelog = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/tag/v${finalAttrs.version}";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ iedame ];
    # Heroic may work on nix-darwin, but it needs a dedicated maintainer for the platform.
    # It may also work on other Linux targets, but all the game stores only
    # support x86 Linux, so it would require extra hacking to run games via QEMU
    # user emulation.  Upstream provide Linux builds only for x86_64.
    platforms = [ "x86_64-linux" ];
    mainProgram = "heroic";
  };
})
+71 −0
Original line number Diff line number Diff line
From a98cc23b288e13665c8698eec56e0653613946d7 Mon Sep 17 00:00:00 2001
From: Aidan Gauland <aidalgol@fastmail.net>
Date: Tue, 19 Aug 2025 09:45:55 +1200
Subject: [PATCH] [Fix] Run GalaxyComm executable path through fixAsarPath

---
 src/backend/constants/paths.ts |  4 ++++
 src/backend/launcher.ts        | 15 +++++----------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/backend/constants/paths.ts b/src/backend/constants/paths.ts
index 1d05ce5b58..2e9cff1197 100644
--- a/src/backend/constants/paths.ts
+++ b/src/backend/constants/paths.ts
@@ -44,6 +44,10 @@ export const fakeEpicExePath = fixAsarPath(
   join(publicDir, 'bin', 'x64', 'win32', 'EpicGamesLauncher.exe')
 )
 
+export const galaxyCommunicationExePath = fixAsarPath(
+  join(publicDir, 'bin', 'x64', 'win32', 'GalaxyCommunication.exe')
+)
+
 export const webviewPreloadPath = fixAsarPath(
   join('file://', publicDir, 'webviewPreload.js')
 )
diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts
index a239cff927..2262dc35b2 100644
--- a/src/backend/launcher.ts
+++ b/src/backend/launcher.ts
@@ -80,7 +80,7 @@ import {
   defaultWinePrefix,
   fixesPath,
   flatpakHome,
-  publicDir,
+  galaxyCommunicationExePath,
   runtimePath,
   userHome
 } from './constants/paths'
@@ -888,28 +888,23 @@ async function prepareWineLaunch(
 
   try {
     if (runner === 'gog' && experimentalFeatures?.cometSupport !== false) {
-      const communicationSource = join(
-        publicDir,
-        'bin/x64/win32/GalaxyCommunication.exe'
-      )
-
-      const galaxyCommPath =
+      const galaxyCommWinePath =
         'C:\\ProgramData\\GOG.com\\Galaxy\\redists\\GalaxyCommunication.exe'
       const communicationDest = await getWinePath({
-        path: galaxyCommPath,
+        path: galaxyCommWinePath,
         gameSettings,
         variant: 'unix'
       })
 
       if (!existsSync(communicationDest)) {
         mkdirSync(dirname(communicationDest), { recursive: true })
-        await copyFile(communicationSource, communicationDest)
+        await copyFile(galaxyCommunicationExePath, communicationDest)
         await runWineCommand({
           commandParts: [
             'sc',
             'create',
             'GalaxyCommunication',
-            `binpath=${galaxyCommPath}`
+            `binpath=${galaxyCommWinePath}`
           ],
           gameSettings,
           protonVerb: 'runinprefix'
Loading