2022-08-20 00:26:01 +02:00
|
|
|
{ lib
|
2023-05-04 07:00:01 +02:00
|
|
|
, stdenv
|
2022-08-20 00:26:01 +02:00
|
|
|
, fetchFromGitHub
|
2023-05-04 07:00:01 +02:00
|
|
|
, fetchYarnDeps
|
|
|
|
, yarn
|
2023-11-22 23:03:52 +01:00
|
|
|
, prefetch-yarn-deps
|
2023-05-04 07:00:01 +02:00
|
|
|
, nodejs
|
|
|
|
, python3
|
2022-08-20 00:26:01 +02:00
|
|
|
, makeWrapper
|
|
|
|
, electron
|
2023-09-14 22:01:16 +02:00
|
|
|
, vulkan-helper
|
2022-08-20 00:26:01 +02:00
|
|
|
, gogdl
|
|
|
|
, legendary-gl
|
2023-07-31 05:05:58 +02:00
|
|
|
, nile
|
2022-08-20 00:26:01 +02:00
|
|
|
}:
|
|
|
|
|
2023-05-04 07:00:01 +02:00
|
|
|
let appName = "heroic";
|
|
|
|
in stdenv.mkDerivation rec {
|
2022-08-20 00:26:01 +02:00
|
|
|
pname = "heroic-unwrapped";
|
2024-01-07 21:04:37 +01:00
|
|
|
version = "2.12.0";
|
2022-08-20 00:26:01 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Heroic-Games-Launcher";
|
|
|
|
repo = "HeroicGamesLauncher";
|
|
|
|
rev = "v${version}";
|
2024-01-07 21:04:37 +01:00
|
|
|
hash = "sha256-1+TqIExvZHE3X38Fh43CasmTyjIr2WcEw07ZJEFrcBw=";
|
2021-12-03 21:57:34 +01:00
|
|
|
};
|
|
|
|
|
2023-05-04 07:00:01 +02:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = "${src}/yarn.lock";
|
2024-01-07 21:04:37 +01:00
|
|
|
hash = "sha256-27r6lZiD1Ptk0WIYdwNLSZy6iMnmaZjKXBUjr+5+1lQ=";
|
2023-05-04 07:00:01 +02:00
|
|
|
};
|
2022-08-20 00:26:01 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2023-05-04 07:00:01 +02:00
|
|
|
yarn
|
2023-11-22 23:03:52 +01:00
|
|
|
prefetch-yarn-deps
|
2023-05-04 07:00:01 +02:00
|
|
|
nodejs
|
|
|
|
python3
|
2022-08-20 00:26:01 +02:00
|
|
|
makeWrapper
|
|
|
|
];
|
2021-12-03 21:57:34 +01:00
|
|
|
|
2023-08-01 06:31:19 +02:00
|
|
|
patches = [
|
|
|
|
# Reverts part of upstream PR 2761 so that we don't have to use a non-free Electron fork.
|
|
|
|
# https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/pull/2761
|
|
|
|
./remove-drm-support.patch
|
2023-08-18 22:06:17 +02:00
|
|
|
# Make Heroic create Steam shortcuts (to non-steam games) with the correct path to heroic.
|
|
|
|
./fix-non-steam-shortcuts.patch
|
2023-08-01 06:31:19 +02:00
|
|
|
];
|
|
|
|
|
2023-11-04 21:11:33 +01:00
|
|
|
postPatch = ''
|
|
|
|
# We are not packaging this as an Electron application bundle, so Electron
|
|
|
|
# reports to the application that is is not "packaged", which causes Heroic
|
|
|
|
# to take some incorrect codepaths meant for development environments.
|
|
|
|
substituteInPlace src/**/*.ts --replace 'app.isPackaged' 'true'
|
|
|
|
'';
|
|
|
|
|
2023-05-04 07:00:01 +02:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
2022-08-20 00:26:01 +02:00
|
|
|
|
2023-05-04 07:00:01 +02:00
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
yarn config --offline set yarn-offline-mirror $offlineCache
|
2023-11-22 23:03:52 +01:00
|
|
|
fixup-yarn-lock yarn.lock
|
2023-05-04 07:00:01 +02:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
patchShebangs node_modules/
|
|
|
|
|
|
|
|
runHook postConfigure
|
2022-08-20 00:26:01 +02:00
|
|
|
'';
|
2021-12-03 21:57:34 +01:00
|
|
|
|
2023-05-04 07:00:01 +02:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
yarn --offline vite build
|
|
|
|
|
|
|
|
# Remove dev dependencies.
|
|
|
|
yarn install --production --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2021-12-03 21:57:34 +01:00
|
|
|
|
2022-08-20 00:26:01 +02:00
|
|
|
# --disable-gpu-compositing is to work around upstream bug
|
|
|
|
# https://github.com/electron/electron/issues/32317
|
2023-05-04 07:00:01 +02:00
|
|
|
installPhase = let
|
|
|
|
binPlatform = if stdenv.isDarwin then "darwin" else "linux";
|
2022-08-20 00:26:01 +02:00
|
|
|
in ''
|
2023-05-04 07:00:01 +02:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/share/{applications,${appName}}
|
|
|
|
cp -r . $out/share/${appName}
|
|
|
|
rm -rf $out/share/${appName}/{.devcontainer,.vscode,.husky,.idea,.github}
|
|
|
|
|
|
|
|
chmod -R u+w "$out/share/${appName}/public/bin" "$out/share/${appName}/build/bin"
|
|
|
|
rm -rf "$out/share/${appName}/public/bin" "$out/share/${appName}/build/bin"
|
|
|
|
mkdir -p "$out/share/${appName}/build/bin/${binPlatform}"
|
2023-07-31 05:05:58 +02:00
|
|
|
ln -s \
|
|
|
|
"${gogdl}/bin/gogdl" \
|
|
|
|
"${legendary-gl}/bin/legendary" \
|
2023-09-14 22:01:16 +02:00
|
|
|
"${nile}/bin/nile" \
|
|
|
|
"${lib.optionalString stdenv.isLinux "${vulkan-helper}/bin/vulkan-helper"}" \
|
2023-07-31 05:05:58 +02:00
|
|
|
"$out/share/${appName}/build/bin/${binPlatform}"
|
2021-12-03 21:57:34 +01:00
|
|
|
|
2022-08-20 00:26:01 +02:00
|
|
|
makeWrapper "${electron}/bin/electron" "$out/bin/heroic" \
|
|
|
|
--inherit-argv0 \
|
|
|
|
--add-flags --disable-gpu-compositing \
|
2023-05-04 07:00:01 +02:00
|
|
|
--add-flags $out/share/${appName} \
|
2023-08-21 09:32:46 +02:00
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}"
|
2021-12-03 21:57:34 +01:00
|
|
|
|
2023-05-04 07:00:01 +02:00
|
|
|
substituteInPlace "$out/share/${appName}/flatpak/com.heroicgameslauncher.hgl.desktop" \
|
2022-08-20 00:26:01 +02:00
|
|
|
--replace "Exec=heroic-run" "Exec=heroic"
|
|
|
|
mkdir -p "$out/share/applications" "$out/share/icons/hicolor/512x512/apps"
|
2023-05-04 07:00:01 +02:00
|
|
|
ln -s "$out/share/${appName}/flatpak/com.heroicgameslauncher.hgl.desktop" "$out/share/applications"
|
|
|
|
ln -s "$out/share/${appName}/flatpak/com.heroicgameslauncher.hgl.png" "$out/share/icons/hicolor/512x512/apps"
|
|
|
|
|
|
|
|
runHook postInstall
|
2021-12-03 21:57:34 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2023-07-31 05:05:58 +02:00
|
|
|
description = "A Native GOG, Epic, and Amazon Games Launcher for Linux, Windows and Mac";
|
2021-12-03 21:57:34 +01:00
|
|
|
homepage = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher";
|
2023-05-01 11:29:14 +02:00
|
|
|
changelog = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases";
|
2021-12-03 21:57:34 +01:00
|
|
|
license = licenses.gpl3Only;
|
2022-08-20 00:26:01 +02:00
|
|
|
maintainers = with maintainers; [ aidalgol ];
|
2023-05-04 07:00:01 +02:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
|
|
|
mainProgram = appName;
|
2021-12-03 21:57:34 +01:00
|
|
|
};
|
|
|
|
}
|