From e717dfc32b35162541bbf09ee59f22c5e9e833ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sat, 20 Jul 2024 19:43:23 +0200 Subject: [PATCH] Add awakened-poe-trade --- home/packages/default.nix | 2 + packages/awakened-poe-trade.nix | 138 ++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 packages/awakened-poe-trade.nix diff --git a/home/packages/default.nix b/home/packages/default.nix index 15ce0e1..e5ab26d 100644 --- a/home/packages/default.nix +++ b/home/packages/default.nix @@ -2,6 +2,7 @@ let withCuda = if (osConfig.system.name == "gunter") then true else false; pob = pkgs.qt6Packages.callPackage ../../packages/pob.nix { }; + awakened-poe-trade = pkgs.callPackage ../../packages/awakened-poe-trade.nix { }; in { home.packages = with pkgs; [ @@ -106,5 +107,6 @@ in (prismlauncher.override { withWaylandGLFW = true; }) pob + awakened-poe-trade ]; } diff --git a/packages/awakened-poe-trade.nix b/packages/awakened-poe-trade.nix new file mode 100644 index 0000000..f4bedbd --- /dev/null +++ b/packages/awakened-poe-trade.nix @@ -0,0 +1,138 @@ +{ + stdenv, + lib, + fetchFromGitHub, + fetchYarnDeps, + yarn, + yarnConfigHook, + yarnBuildHook, + makeWrapper, + libGL, + nodejs, + electron, + xorg, + wayland, + libglvnd, + npmHooks, +}: +let + pkgVersion = "3.24.10004"; + + pkgSrc = fetchFromGitHub { + owner = "SnosMe"; + repo = "awakened-poe-trade"; + rev = "v${pkgVersion}"; + hash = "sha256-khIJIOT5Us792YThruNZfnpfBrcPS/vjoAdLI6V4Nwo="; + }; + + yarnCacheRenderer = fetchYarnDeps { + yarnLock = pkgSrc + "/renderer/yarn.lock"; + hash = "sha256-hOfE8XCu1Y4yZzOKHhaNkqKxJ6gxZS5SLRlBxvq3LwY="; + }; + + yarnCacheMain = fetchYarnDeps { + yarnLock = pkgSrc + "/main/yarn.lock"; + hash = "sha256-VLDsqCKrNF7Smywg3yRrjgMG0lmZt8uzeTHKr5n2JMw="; + }; + + renderer = stdenv.mkDerivation (finalAttrs: { + pname = "awakened-poe-trade-renderer"; + version = "${pkgVersion}"; + src = pkgSrc; + sourceRoot = "${finalAttrs.src.name}/renderer"; + + yarnOfflineCache = yarnCacheRenderer; + + buildPhase = '' + yarn make-index-files + runHook yarnBuildHook + ''; + + installPhase = '' + mkdir -p $out + cp -r dist $out; + ''; + + nativeBuildInputs = [ + yarnConfigHook + yarnBuildHook + nodejs + ]; + }); +in +stdenv.mkDerivation (finalAttrs: { + pname = "awakened-poe-trade"; + version = "${pkgVersion}"; + src = pkgSrc; + sourceRoot = "${finalAttrs.src.name}/main"; + + yarnOfflineCache = yarnCacheMain; + + patchPhase = '' + find . + substituteInPlace electron-builder.yml \ + --replace-fail "../renderer/dist" "${renderer}/dist" \ + --replace-fail "AppImage" "dir" + cat electron-builder.yml + find "${renderer}" + ''; + + env = { + ELECTRON_SKIP_BINARY_DOWNLOAD = 1; + ELECTRON_OVERRIDE_DIST_PATH = "${electron}"; + }; + + nativeBuildInputs = [ + yarnConfigHook + yarnBuildHook + yarn + nodejs + electron + makeWrapper + renderer + ]; + + # yarnBuildScript = "electron-builder"; + # yarnBuildFlags = [ + # "--dir" + # "-c.electronDist=${electron}/libexec/electron" + # "-c.electronVersion=${electron.version}" + # ]; + buildPhase = '' + runHook yarnBuildHook + yarn run electron-builder --dir -c.electronDist=${electron}/libexec/electron -c.electronVersion=${electron.version} + find dist + ''; + + installPhase = '' + runHook preInstall + mkdir -p "$out/share/lib/awakened-poe-trade" + cp -r ./dist/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/awakened-poe-trade" + cp -r "${renderer}/dist/data" "$out/share/lib/awakened-poe-trade/resources/data" + echo "${renderer}" + + makeWrapper '${electron}/bin/electron' "$out/bin/awakened-poe-trade" \ + --set LD_LIBRARY_PATH "${ + lib.makeLibraryPath [ + libGL + xorg.libXtst + xorg.libXt + wayland + libglvnd + ] + }" \ + --add-flags "$out/share/lib/awakened-poe-trade/resources/app.asar" \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ + --inherit-argv0 + runHook postInstall + ''; + + buildInputs = [ electron ]; + + meta = { + description = "Path of Exile trading app for price checking"; + homepage = "https://github.com/SnosMe/awakened-poe-trade"; + license = lib.licenses.mit; + mainProgram = "pobfrontend"; + }; +})