pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / games / heroic / default.nix
blobad68279740d6044cd769f74f3a29cc41aa220772
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   nix-update-script,
6   pnpm,
7   nodejs,
8   makeWrapper,
9   electron,
10   vulkan-helper,
11   gogdl,
12   legendary-gl,
13   nile,
14   comet-gog,
17 stdenv.mkDerivation (finalAttrs: {
18   pname = "heroic-unwrapped";
19   version = "2.15.2";
21   src = fetchFromGitHub {
22     owner = "Heroic-Games-Launcher";
23     repo = "HeroicGamesLauncher";
24     rev = "v${finalAttrs.version}";
25     hash = "sha256-AndJqk1VAUdC4pOTRzyfhdxmzJMskGF6pUiqPs3fIy4=";
26   };
28   pnpmDeps = pnpm.fetchDeps {
29     inherit (finalAttrs) pname version src;
30     hash = "sha256-/7JIeQZt3QsKrjujSucRLiHfhfSllK7FeumNA4eHqSY=";
31   };
33   nativeBuildInputs = [
34     nodejs
35     pnpm.configHook
36     makeWrapper
37   ];
39   patches = [
40     # Make Heroic create Steam shortcuts (to non-steam games) with the correct path to heroic.
41     ./fix-non-steam-shortcuts.patch
42   ];
44   postPatch = ''
45     # We are not packaging this as an Electron application bundle, so Electron
46     # reports to the application that is is not "packaged", which causes Heroic
47     # to take some incorrect codepaths meant for development environments.
48     substituteInPlace src/**/*.ts --replace-quiet 'app.isPackaged' 'true'
49   '';
51   buildPhase = ''
52     runHook preBuild
54     pnpm --offline electron-vite build
55     # Remove dev dependencies.
56     pnpm --ignore-scripts prune --prod
57     # Clean up broken symlinks left behind by `pnpm prune`
58     find node_modules/.bin -xtype l -delete
60     runHook postBuild
61   '';
63   # --disable-gpu-compositing is to work around upstream bug
64   # https://github.com/electron/electron/issues/32317
65   installPhase = ''
66     runHook preInstall
68     mkdir -p $out/share/{applications,heroic}
69     cp -r . $out/share/heroic
70     rm -rf $out/share/heroic/{.devcontainer,.vscode,.husky,.idea,.github}
72     chmod -R u+w "$out/share/heroic/public/bin" "$out/share/heroic/build/bin"
73     rm -rf "$out/share/heroic/public/bin" "$out/share/heroic/build/bin"
74     mkdir -p "$out/share/heroic/build/bin/x64/linux"
75     ln -s \
76       "${lib.getExe gogdl}" \
77       "${lib.getExe legendary-gl}" \
78       "${lib.getExe nile}" \
79       "${lib.getExe comet-gog}" \
80       "${lib.getExe vulkan-helper}" \
81       "$out/share/heroic/build/bin/x64/linux/"
83     makeWrapper "${electron}/bin/electron" "$out/bin/heroic" \
84       --inherit-argv0 \
85       --add-flags --disable-gpu-compositing \
86       --add-flags $out/share/heroic \
87       --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}"
89     substituteInPlace "$out/share/heroic/flatpak/com.heroicgameslauncher.hgl.desktop" \
90       --replace-fail "Exec=heroic-run" "Exec=heroic"
91     mkdir -p "$out/share/applications" "$out/share/icons/hicolor/scalable/apps"
92     ln -s "$out/share/heroic/flatpak/com.heroicgameslauncher.hgl.desktop" "$out/share/applications"
93     ln -s "$out/share/heroic/src/frontend/assets/heroic-icon.svg" "$out/share/icons/hicolor/scalable/apps/com.heroicgameslauncher.hgl.svg"
95     runHook postInstall
96   '';
98   passthru = {
99     inherit (finalAttrs) pnpmDeps;
100     updateScript = nix-update-script { };
101   };
103   meta = with lib; {
104     description = "Native GOG, Epic, and Amazon Games Launcher for Linux, Windows and Mac";
105     homepage = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher";
106     changelog = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases";
107     license = licenses.gpl3Only;
108     maintainers = with maintainers; [ aidalgol ];
109     # Heroic may work on nix-darwin, but it needs a dedicated maintainer for the platform.
110     # It may also work on other Linux targets, but all the game stores only
111     # support x86 Linux, so it would require extra hacking to run games via QEMU
112     # user emulation.  Upstream provide Linux builds only for x86_64.
113     platforms = [ "x86_64-linux" ];
114     mainProgram = "heroic";
115   };