1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 unzip,
6 meson,
7 ninja,
8 pkg-config,
9 qtbase,
10 qttools,
11 wrapQtAppsHook,
12 icoutils,
13 copyDesktopItems,
14 makeDesktopItem,
15 luajit,
16}:
17let
18 data = stdenv.mkDerivation (finalAttrs: {
19 pname = "path-of-building-data";
20 version = "2.55.5";
21
22 src = fetchFromGitHub {
23 owner = "PathOfBuildingCommunity";
24 repo = "PathOfBuilding";
25 rev = "v${finalAttrs.version}";
26 hash = "sha256-0FgLVQZBv366ACw8zXt72fARdQqFZf4l4lfvt85KpSs=";
27 };
28
29 nativeBuildInputs = [ unzip ];
30
31 buildCommand = ''
32 # I have absolutely no idea how this file is generated
33 # and I don't think I want to know. The Flatpak also does this.
34 unzip -j -d $out $src/runtime-win32.zip lua/sha1.lua
35
36 # Install the actual data
37 cp -r $src/src $src/runtime/lua/*.lua $src/manifest.xml $out
38
39 # Pretend this is an official build so we don't get the ugly "dev mode" warning
40 substituteInPlace $out/manifest.xml --replace '<Version' '<Version platform="nixos"'
41 touch $out/installed.cfg
42
43 # Completely stub out the update check
44 chmod +w $out/src/UpdateCheck.lua
45 echo 'return "none"' > $out/src/UpdateCheck.lua
46 '';
47 });
48in
49stdenv.mkDerivation {
50 pname = "path-of-building";
51 version = "${data.version}-unstable-2023-04-09";
52
53 src = fetchFromGitHub {
54 owner = "ernstp";
55 repo = "pobfrontend";
56 rev = "9faa19aa362f975737169824c1578d5011487c18";
57 hash = "sha256-zhw2PZ6ZNMgZ2hG+a6AcYBkeg7kbBHNc2eSt4if17Wk=";
58 };
59
60 nativeBuildInputs = [
61 meson
62 ninja
63 pkg-config
64 qttools
65 wrapQtAppsHook
66 icoutils
67 ]
68 ++ lib.optional stdenv.hostPlatform.isLinux copyDesktopItems;
69
70 buildInputs = [
71 qtbase
72 luajit
73 luajit.pkgs.lua-curl
74 luajit.pkgs.luautf8
75 ];
76
77 installPhase = ''
78 runHook preInstall
79 install -Dm555 pobfrontend $out/bin/pobfrontend
80
81 wrestool -x -t 14 ${data.src}/runtime/Path{space}of{space}Building.exe -o pathofbuilding.ico
82 icotool -x pathofbuilding.ico
83
84 for size in 16 32 48 256; do
85 mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
86 install -Dm 644 pathofbuilding*"$size"x"$size"*.png \
87 $out/share/icons/hicolor/"$size"x"$size"/apps/pathofbuilding.png
88 done
89 rm pathofbuilding.ico
90
91 runHook postInstall
92 '';
93
94 preFixup = ''
95 qtWrapperArgs+=(
96 --set LUA_PATH "$LUA_PATH"
97 --set LUA_CPATH "$LUA_CPATH"
98 --chdir "${data}"
99 )
100 '';
101
102 desktopItems = [
103 (makeDesktopItem {
104 name = "path-of-building";
105 desktopName = "Path of Building";
106 comment = "Offline build planner for Path of Exile";
107 exec = "pobfrontend %U";
108 terminal = false;
109 type = "Application";
110 icon = "pathofbuilding";
111 categories = [ "Game" ];
112 keywords = [
113 "poe"
114 "pob"
115 "pobc"
116 "path"
117 "exile"
118 ];
119 mimeTypes = [ "x-scheme-handler/pob" ];
120 })
121 ];
122
123 passthru.data = data;
124
125 meta = {
126 description = "Offline build planner for Path of Exile";
127 homepage = "https://pathofbuilding.community/";
128 license = lib.licenses.mit;
129 maintainers = [ lib.maintainers.k900 ];
130 mainProgram = "pobfrontend";
131 broken = stdenv.hostPlatform.isDarwin; # doesn't find uic6 for some reason
132 };
133}