about summary refs log tree commit diff
path: root/nixpkgs/pkgs/games/heroic
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-06-16 06:56:35 +0000
committerAlyssa Ross <hi@alyssa.is>2023-06-16 06:56:35 +0000
commit99fcaeccb89621dd492203ce1f2d551c06f228ed (patch)
tree41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/pkgs/games/heroic
parent59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff)
parent75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff)
downloadnixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts:
	nixpkgs/nixos/modules/config/console.nix
	nixpkgs/nixos/modules/services/mail/mailman.nix
	nixpkgs/nixos/modules/services/mail/public-inbox.nix
	nixpkgs/nixos/modules/services/mail/rss2email.nix
	nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
	nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix
	nixpkgs/pkgs/applications/networking/irc/weechat/default.nix
	nixpkgs/pkgs/applications/window-managers/sway/default.nix
	nixpkgs/pkgs/build-support/go/module.nix
	nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
	nixpkgs/pkgs/development/interpreters/python/default.nix
	nixpkgs/pkgs/development/node-packages/overrides.nix
	nixpkgs/pkgs/development/tools/b4/default.nix
	nixpkgs/pkgs/servers/dict/dictd-db.nix
	nixpkgs/pkgs/servers/mail/public-inbox/default.nix
	nixpkgs/pkgs/tools/security/pinentry/default.nix
	nixpkgs/pkgs/tools/text/unoconv/default.nix
	nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/games/heroic')
-rw-r--r--nixpkgs/pkgs/games/heroic/default.nix114
-rw-r--r--nixpkgs/pkgs/games/heroic/fhsenv.nix125
2 files changed, 214 insertions, 25 deletions
diff --git a/nixpkgs/pkgs/games/heroic/default.nix b/nixpkgs/pkgs/games/heroic/default.nix
index 044d159cde1d..1baf9cbf8163 100644
--- a/nixpkgs/pkgs/games/heroic/default.nix
+++ b/nixpkgs/pkgs/games/heroic/default.nix
@@ -1,39 +1,103 @@
-{ lib, fetchurl, appimageTools }:
-
-let
-  pname = "heroic";
-  version = "2.2.6";
-  name = "${pname}-${version}";
-  src = fetchurl {
-    url = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v${version}/Heroic-${version}.AppImage";
-    sha256 = "sha256-kL30/G4DpDPwGN7PvbWest7TcgL4Rd1c2OM4nRCT3bg=";
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchYarnDeps
+, yarn
+, fixup_yarn_lock
+, nodejs
+, python3
+, makeWrapper
+, electron
+, gogdl
+, legendary-gl
+}:
+
+let appName = "heroic";
+in stdenv.mkDerivation rec {
+  pname = "heroic-unwrapped";
+  version = "2.8.0";
+
+  src = fetchFromGitHub {
+    owner = "Heroic-Games-Launcher";
+    repo = "HeroicGamesLauncher";
+    rev = "v${version}";
+    hash = "sha256-AZwJRBkWuzBPT+ADVHabiK2KRXe6clZFa0IO99BO2Wk=";
+  };
+
+  offlineCache = fetchYarnDeps {
+    yarnLock = "${src}/yarn.lock";
+    hash = "sha256-xiLK0D9+oL2UMD7b/9htOQJEpYCNayKW+KJ/vNVCgsw=";
   };
-  appimageContents = appimageTools.extractType2 { inherit name src; };
 
-in
-appimageTools.wrapType2 {
-  inherit name src;
+  nativeBuildInputs = [
+    yarn
+    fixup_yarn_lock
+    nodejs
+    python3
+    makeWrapper
+  ];
+
+  configurePhase = ''
+    runHook preConfigure
+
+    export HOME=$(mktemp -d)
+    yarn config --offline set yarn-offline-mirror $offlineCache
+    fixup_yarn_lock yarn.lock
+    yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
+    patchShebangs node_modules/
+
+    runHook postConfigure
+  '';
+
+  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
+  '';
+
+  # --disable-gpu-compositing is to work around upstream bug
+  # https://github.com/electron/electron/issues/32317
+  installPhase = let
+    binPlatform = if stdenv.isDarwin then "darwin" else "linux";
+  in ''
+    runHook preInstall
 
-  extraInstallCommands = ''
-    mv $out/bin/${name} $out/bin/${pname}
+    mkdir -p $out/share/{applications,${appName}}
+    cp -r . $out/share/${appName}
+    rm -rf $out/share/${appName}/{.devcontainer,.vscode,.husky,.idea,.github}
 
-    mkdir -p $out/share/${pname}
-    cp -a ${appimageContents}/locales $out/share/${pname}
-    cp -a ${appimageContents}/resources $out/share/${pname}
+    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}"
+    ln -s "${gogdl}/bin/gogdl" "${legendary-gl}/bin/legendary" "$out/share/${appName}/build/bin/${binPlatform}"
 
-    install -m 444 -D ${appimageContents}/heroic.desktop -t $out/share/applications
+    makeWrapper "${electron}/bin/electron" "$out/bin/heroic" \
+      --inherit-argv0 \
+      --add-flags --disable-gpu-compositing \
+      --add-flags $out/share/${appName} \
+      --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
 
-    cp -a ${appimageContents}/usr/share/icons $out/share/
+    substituteInPlace "$out/share/${appName}/flatpak/com.heroicgameslauncher.hgl.desktop" \
+      --replace "Exec=heroic-run" "Exec=heroic"
+    mkdir -p "$out/share/applications" "$out/share/icons/hicolor/512x512/apps"
+    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"
 
-    substituteInPlace $out/share/applications/heroic.desktop \
-      --replace 'Exec=AppRun' 'Exec=heroic'
+    runHook postInstall
   '';
 
   meta = with lib; {
-    description = "A Native GUI Epic Games Launcher for Linux, Windows and Mac";
+    description = "A Native GOG and Epic Games Launcher for Linux, Windows and Mac";
     homepage = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher";
+    changelog = "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases";
     license = licenses.gpl3Only;
-    maintainers = with maintainers; [ wolfangaukang ];
-    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ aidalgol ];
+    platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
+    mainProgram = appName;
   };
 }
diff --git a/nixpkgs/pkgs/games/heroic/fhsenv.nix b/nixpkgs/pkgs/games/heroic/fhsenv.nix
new file mode 100644
index 000000000000..d47a567999c2
--- /dev/null
+++ b/nixpkgs/pkgs/games/heroic/fhsenv.nix
@@ -0,0 +1,125 @@
+{ buildFHSEnv
+, heroic-unwrapped
+, extraPkgs ? pkgs: [ ]
+, extraLibraries ? pkgs: [ ]
+}:
+
+buildFHSEnv {
+  name = "heroic";
+
+  runScript = "heroic";
+
+  targetPkgs = pkgs: with pkgs; [
+    heroic-unwrapped
+    gamemode
+    curl
+    gawk
+    gnome.zenity
+    plasma5Packages.kdialog
+    mangohud
+    nettools
+    opencl-headers
+    p7zip
+    perl
+    psmisc
+    python3
+    which
+    xorg.xrandr
+    zstd
+  ] ++ extraPkgs pkgs;
+
+  multiPkgs = let
+    xorgDeps = pkgs: with pkgs.xorg; [
+      libpthreadstubs
+      libSM
+      libX11
+      libXaw
+      libxcb
+      libXcomposite
+      libXcursor
+      libXdmcp
+      libXext
+      libXi
+      libXinerama
+      libXmu
+      libXrandr
+      libXrender
+      libXv
+      libXxf86vm
+    ];
+  in pkgs: with pkgs; [
+    alsa-lib
+    alsa-plugins
+    bash
+    cabextract
+    cairo
+    coreutils
+    cups
+    dbus
+    freealut
+    freetype
+    fribidi
+    giflib
+    glib
+    gnutls
+    gst_all_1.gst-plugins-base
+    gtk3
+    lcms2
+    libevdev
+    libgcrypt
+    libGLU
+    libglvnd
+    libgpg-error
+    libgudev
+    libjpeg
+    libkrb5
+    libmpeg2
+    libogg
+    libopus
+    libpng
+    libpulseaudio
+    libselinux
+    libsndfile
+    libsoup
+    libtheora
+    libtiff
+    libusb1
+    libv4l
+    libva
+    libvdpau
+    libvorbis
+    libvpx
+    libwebp
+    libxkbcommon
+    libxml2
+    mpg123
+    ncurses
+    ocl-icd
+    openal
+    openldap
+    openssl
+    pango
+    pipewire
+    samba4
+    sane-backends
+    SDL2
+    speex
+    sqlite
+    udev
+    unixODBC
+    util-linux
+    v4l-utils
+    vulkan-loader
+    wayland
+    zlib
+  ] ++ xorgDeps pkgs
+    ++ extraLibraries pkgs;
+
+  extraInstallCommands = ''
+    mkdir -p $out/share
+    ln -s ${heroic-unwrapped}/share/applications $out/share
+    ln -s ${heroic-unwrapped}/share/icons $out/share
+  '';
+
+  meta = heroic-unwrapped.meta;
+}