Initial commit

This commit is contained in:
Torjus Håkestad 2024-07-21 02:41:47 +02:00
commit deee2d91ca
6 changed files with 327 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1721379653,
"narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

40
flake.nix Normal file
View File

@ -0,0 +1,40 @@
{
description = "Various packages not in nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
allSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems =
f: nixpkgs.lib.genAttrs allSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
in
{
overlays = {
default = final: prev: {
ghettoptt = self.packages.${prev.system}.awakened-poe-trade;
path-of-building-beta = self.packages.${prev.system}.path-of-building-beta;
};
awakened-poe-trade = final: prev: {
awakened-poe-trade = self.packages.${prev.system}.awakened-poe-trade;
};
path-of-building-beta = final: prev: {
awakened-poe-trade = self.packages.${prev.system}.path-of-building-beta;
};
};
packages = forAllSystems (
{ pkgs }:
{
awakened-poe-trade = pkgs.callPackage ./pkgs/awakened-poe-trade { };
path-of-building-beta = pkgs.qt6Packages.callPackage ./pkgs/path-of-building-beta { };
}
);
};
}

View File

@ -0,0 +1,137 @@
{
stdenv,
lib,
fetchFromGitHub,
fetchYarnDeps,
yarn,
yarnConfigHook,
yarnBuildHook,
makeWrapper,
libGL,
nodejs,
electron,
xorg,
wayland,
libglvnd,
}:
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 = "awakened-poe-trade";
};
})

View File

@ -0,0 +1,94 @@
{
stdenv,
lib,
fetchFromGitHub,
unzip,
meson,
ninja,
pkg-config,
qtbase,
qttools,
wrapQtAppsHook,
luajit,
}:
let
data = stdenv.mkDerivation (finalAttrs: {
pname = "path-of-building-data";
version = "2.43.0-beta";
src = fetchFromGitHub {
owner = "PathOfBuildingCommunity";
repo = "PathOfBuilding";
rev = "b536f24931c9315cccc9a08ce1d775f2cc1dc713";
hash = "sha256-TNZcMVp7riBlFj2ELuf2jeh/L5dbocWCcsH6EmVY4xs=";
};
nativeBuildInputs = [ unzip ];
buildCommand = ''
# I have absolutely no idea how this file is generated
# and I don't think I want to know. The Flatpak also does this.
unzip -j -d $out $src/runtime-win32.zip lua/sha1.lua
# Install the actual data
cp -r $src/src $src/runtime/lua/*.lua $src/manifest.xml $out
# Pretend this is an official build so we don't get the ugly "dev mode" warning
substituteInPlace $out/manifest.xml --replace '<Version' '<Version platform="nixos"'
touch $out/installed.cfg
# Completely stub out the update check
chmod +w $out/src/UpdateCheck.lua
echo 'return "none"' > $out/src/UpdateCheck.lua
'';
});
in
stdenv.mkDerivation {
pname = "path-of-building";
version = "${data.version}-unstable-2023-04-09";
src = fetchFromGitHub {
owner = "ernstp";
repo = "pobfrontend";
rev = "9faa19aa362f975737169824c1578d5011487c18";
hash = "sha256-zhw2PZ6ZNMgZ2hG+a6AcYBkeg7kbBHNc2eSt4if17Wk=";
};
nativeBuildInputs = [
meson
ninja
pkg-config
qttools
wrapQtAppsHook
];
buildInputs = [
qtbase
luajit
luajit.pkgs.lua-curl
];
installPhase = ''
runHook preInstall
install -Dm555 pobfrontend $out/bin/pobfrontend
runHook postInstall
'';
preFixup = ''
qtWrapperArgs+=(
--set LUA_PATH "$LUA_PATH"
--set LUA_CPATH "$LUA_CPATH"
--chdir "${data}"
)
'';
passthru.data = data;
meta = {
description = "Offline build planner for Path of Exile";
homepage = "https://pathofbuilding.community/";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.k900 ];
mainProgram = "pobfrontend";
broken = stdenv.isDarwin; # doesn't find uic6 for some reason
};
}

28
scripts/update-pob.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -eo pipefail
# set -x
# TODO: Update pobfrontend as well?
POB_NIX_FILE="pkgs/path-of-building-beta/default.nix"
if [ -z "$1" ]; then
nurl_output=$(nurl -j https://github.com/PathOfBuildingCommunity/PathOfBuilding 2>/dev/null)
rev=$(jq '.args.rev' <<< "$nurl_output")
else
nurl_output=$(nurl -j https://github.com/PathOfBuildingCommunity/PathOfBuilding "$1" 2>/dev/null)
fi
hash=$(jq '.args.hash' <<< "$nurl_output" | sed 's/\//\\\//g')
echo "Updating pob to $rev"
# Find lines to replace
rev_line_numbers=$(grep -Fn "rev =" $POB_NIX_FILE| cut -d":" -f1)
rev_line_data=$(head -n1 <<< "$rev_line_numbers")
sed -i "${rev_line_data}s/.*/ rev = $rev;/" $POB_NIX_FILE
hash_line_numbers=$(grep -Fn "hash =" $POB_NIX_FILE| cut -d":" -f1)
hash_line_data=$(head -n1 <<< "$hash_line_numbers")
sed -i "${hash_line_data}s/.*/ hash = $hash;/" $POB_NIX_FILE
nixfmt $POB_NIX_FILE