legends-of-equestria: add darwin support

This commit is contained in:
Ulysses Zhan
2025-01-05 11:23:12 -08:00
parent 8185920473
commit 9c7d8351f0
2 changed files with 110 additions and 40 deletions
@@ -31,6 +31,22 @@ let
pname = "legends-of-equestria";
version = "2024.06.02";
description = "Free-to-play MMORPG";
srcOptions = {
x86_64-linux = {
url = "https://mega.nz/file/Z3oAGYDa#01EfQICR4k5BK56hWFckYKsfgdV36KoU91TvSBwKgxY";
outputHash = "vpVIaRPrZih+ydWszsBF/JgO0AXh2rF/yOpBuI+V0m4=";
};
x86_64-darwin = {
url = "https://mega.nz/file/p6JQUDYC#lBRUK7lmxMHh4OvEyKjfl0W1mOL2VVzAH9rXL5ViiN0";
outputHash = "bvFg4wjltiilCP1oKfgUWThcEq8tzCIP3W/eAd3SxFo=";
};
aarch64-darwin = {
url = "https://mega.nz/file/cvxSzZ4b#eJHLvVHz_zxBiRxGMCBcsl1gV6M6ebQf2tQbNpEqCvk";
outputHash = "1aZGuOgXTLFxwF2FcYEwKA/LRT26uiXupBoqmzq9pFM=";
};
};
runtimeDeps =
[
dbus.lib
@@ -67,17 +83,19 @@ stdenv.mkDerivation {
inherit pname version;
src =
runCommand "mega-loe"
{
inherit pname version;
nativeBuildInputs = [
megacmd
unzip
];
url = "https://mega.nz/file/Z3oAGYDa#01EfQICR4k5BK56hWFckYKsfgdV36KoU91TvSBwKgxY";
outputHashAlgo = "sha256";
outputHash = "vpVIaRPrZih+ydWszsBF/JgO0AXh2rF/yOpBuI+V0m4=";
outputHashMode = "recursive";
}
(
srcOptions.${stdenv.hostPlatform.system}
// {
pname = "${pname}-source";
inherit version;
nativeBuildInputs = [
megacmd
unzip
];
outputHashAlgo = "sha256";
outputHashMode = "recursive";
}
)
''
export HOME=$(mktemp -d)
dest=$HOME/mega-loe
@@ -91,28 +109,42 @@ stdenv.mkDerivation {
buildInputs = [
libgcc
];
nativeBuildInputs = [
makeWrapper
copyDesktopItems
autoPatchelfHook
];
nativeBuildInputs =
[
makeWrapper
]
++ lib.optionals stdenv.hostPlatform.isLinux [
copyDesktopItems
autoPatchelfHook
];
installPhase = ''
runHook preInstall
installPhase =
if stdenv.hostPlatform.isLinux then
''
runHook preInstall
loeHome=$out/lib/${pname}
mkdir -p $loeHome
cp -r Linux/* $loeHome
loeHome=$out/lib/${pname}
mkdir -p $loeHome
cp -r Linux/* $loeHome
makeWrapper $loeHome/LoE.x86_64 $out/bin/LoE \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
makeWrapper $loeHome/LoE.x86_64 $out/bin/LoE \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
icon=$out/share/icons/hicolor/128x128/apps/legends-of-equestria.png
mkdir -p $(dirname $icon)
ln -s $loeHome/LoE_Data/Resources/UnityPlayer.png $icon
icon=$out/share/icons/hicolor/128x128/apps/legends-of-equestria.png
mkdir -p $(dirname $icon)
ln -s $loeHome/LoE_Data/Resources/UnityPlayer.png $icon
runHook postInstall
'';
runHook postInstall
''
else
''
runHook preInstall
mkdir -p $out/Applications
cp -r *.app $out/Applications
runHook postInstall
'';
passthru.updateScript = ./update.sh;
@@ -131,7 +163,7 @@ stdenv.mkDerivation {
meta = {
inherit description;
license = lib.licenses.unfree;
platforms = [ "x86_64-linux" ];
platforms = lib.attrNames srcOptions;
maintainers = with lib.maintainers; [ ulysseszhan ];
mainProgram = "LoE";
homepage = "https://www.legendsofequestria.com";
+49 -11
View File
@@ -1,17 +1,55 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts
#!nix-shell -i bash -p curl megacmd unzip common-updater-scripts
set -eu -o pipefail
DOWNLOADS_PAGE_URL=https://www.legendsofequestria.com/downloads
REGEX='href="(https.+)".+Linux.+v(([0-9]+\.)+[0-9]+)'
ATTR=legends-of-equestria
DOWNLOADS_PAGE=https://www.legendsofequestria.com/downloads
OLD_VERSION=$(nix-instantiate --eval -A $ATTR.version | tr -d '"')
TMP=$(mktemp -d)
if [[ $(curl -s $DOWNLOADS_PAGE_URL | grep -Fi Linux) =~ $REGEX ]]; then
url="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"
else
echo "cannot find the latest version"
exit 1
fi
findHash() {
system=$1
url="$2"
update-source-version legends-of-equestria "$version" "" "$url"
mkdir -p $TMP/$system/{download,out}
oldpwd="$(pwd)"
cd $TMP/$system
echo "downloading to $(pwd)/download..." >&2
HOME=$TMP mega-get "$url" download >&2
echo "unzipping to $(pwd)/out..." >&2
unzip -q -d out download/*.zip
nix-hash --to-sri --type sha256 $(nix-hash --type sha256 out)
cd "$oldpwd"
}
applyUpdate() {
system=$1
echo "checking for updates for $system..." >&2
systemText="$2"
regex='<a href="(https.+)">'"$systemText"'</a>.+v(([0-9]+\.)+[0-9]+)'
if [[ "$(curl -s $DOWNLOADS_PAGE | grep -Fi "$systemText")" =~ $regex ]]; then
url="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"
echo "$version $url" >&2
else
echo "cannot find the latest version for $system" >&2
exit 1
fi
if [[ $OLD_VERSION == $version ]]; then
echo "already up-to-date at version $version" >&2
exit 1
fi
hash="$(findHash $system "$url" | sed -E 's/sha256-(.+)/\1/')"
echo "output hash: $hash" >&2
update-source-version $ATTR $version "$hash" "$url" --system=$system --ignore-same-version --ignore-same-hash
}
applyUpdate x86_64-linux Linux
applyUpdate x86_64-darwin macOS
applyUpdate aarch64-darwin "macOS arm64"