From 2cd3559346f56f994194d5999189ba9aa187ce6f Mon Sep 17 00:00:00 2001 From: Ulysses Zhan Date: Fri, 15 Mar 2024 18:41:50 -0700 Subject: [PATCH] legends-of-equestria: init at 2024.05.01 --- .../le/legends-of-equestria/package.nix | 138 ++++++++++++++++++ .../by-name/le/legends-of-equestria/update.sh | 17 +++ 2 files changed, 155 insertions(+) create mode 100644 pkgs/by-name/le/legends-of-equestria/package.nix create mode 100755 pkgs/by-name/le/legends-of-equestria/update.sh diff --git a/pkgs/by-name/le/legends-of-equestria/package.nix b/pkgs/by-name/le/legends-of-equestria/package.nix new file mode 100644 index 0000000000000..25c55ac77c4c7 --- /dev/null +++ b/pkgs/by-name/le/legends-of-equestria/package.nix @@ -0,0 +1,138 @@ +{ + lib, + stdenv, + runCommand, + megacmd, + unzip, + makeWrapper, + autoPatchelfHook, + makeDesktopItem, + copyDesktopItems, + libgcc, + dbus, + xorg_sys_opengl, + systemd, + libcap, + libdrm, + pulseaudio, + libsndfile, + flac, + libvorbis, + libopus, + mpg123, + lame, + libGL, + vulkan-loader, + libasyncns, + xorg, +}: + +let + pname = "legends-of-equestria"; + version = "2024.05.01"; + description = "Free-to-play MMORPG"; + runtimeDeps = + [ + dbus.lib + xorg_sys_opengl + systemd + libcap.lib + libdrm + pulseaudio + libsndfile + flac + libvorbis + mpg123 + lame.lib + libGL + vulkan-loader + libasyncns + ] + ++ (with xorg; [ + libX11 + libxcb + libXau + libXdmcp + libXext + libXcursor + libXrender + libXfixes + libXinerama + libXi + libXrandr + libXScrnSaver + ]); +in +stdenv.mkDerivation { + inherit pname version; + src = + runCommand "mega-loe" + { + inherit pname version; + nativeBuildInputs = [ + megacmd + unzip + ]; + url = "https://mega.nz/file/NjIwwJoK#MVi3C3FAcSQPd7FRpQc0CoStBG8jSFuPn0jD-pG3zY0"; + outputHashAlgo = "sha256"; + outputHash = "VXBtEB3G5MTrWn9OOvmCG3sDoasjbKkLJruhdQZa4SQ="; + outputHashMode = "recursive"; + } + '' + export HOME=$TMPDIR + dest="$TMPDIR/mega-loe" + mkdir -p "$dest" + mega-get "$url" "$dest" + mkdir -p "$out" + unzip -d "$out" "$dest/$(ls "$dest")" + ''; + + dontBuild = true; + buildInputs = [ + libgcc + ]; + nativeBuildInputs = [ + makeWrapper + copyDesktopItems + autoPatchelfHook + ]; + + installPhase = '' + mkdir -p $out/libexec + cp -r LoE $out/libexec + + mkdir -p $out/bin + chmod +x $out/libexec/LoE/LoE.x86_64 + makeWrapper $out/libexec/LoE/LoE.x86_64 $out/bin/LoE \ + --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" + + mkdir -p $out/share/icons/hicolor/128x128/apps + ln -s $out/libexec/LoE/LoE_Data/Resources/UnityPlayer.png \ + $out/share/icons/hicolor/128x128/apps/legends-of-equestria.png + ''; + + passthru.updateScript = ./update.sh; + + desktopItems = [ + (makeDesktopItem { + name = "legends-of-equestria"; + comment = description; + desktopName = "Legends of Equestria"; + genericName = "Legends of Equestria"; + exec = "LoE"; + icon = "legends-of-equestria"; + categories = [ "Game" ]; + }) + ]; + + meta = { + inherit description; + license = lib.licenses.unfree; + platforms = [ "x86_64-linux" ]; + maintainers = with lib.maintainers; [ ulysseszhan ]; + mainProgram = "LoE"; + homepage = "https://www.legendsofequestria.com"; + downloadPage = "https://www.legendsofequestria.com/downloads"; + }; + +} diff --git a/pkgs/by-name/le/legends-of-equestria/update.sh b/pkgs/by-name/le/legends-of-equestria/update.sh new file mode 100755 index 0000000000000..7aef3fd0f4886 --- /dev/null +++ b/pkgs/by-name/le/legends-of-equestria/update.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl common-updater-scripts + +set -eu -o pipefail + +DOWNLOADS_PAGE_URL=https://www.legendsofequestria.com/downloads +REGEX='href="(https.+)".+Linux.+v(([0-9]+\.)+[0-9]+)' + +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 + +update-source-version legends-of-equestria "$version" "" "$url"