working
This commit is contained in:
157
package.nix
Normal file
157
package.nix
Normal file
@@ -0,0 +1,157 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
, dwarfs
|
||||
, makeDesktopItem
|
||||
, copyDesktopItems
|
||||
, makeWrapper
|
||||
, steam-run
|
||||
, patchelf
|
||||
, glibc
|
||||
, zlib
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "opengoal-launcher";
|
||||
version = "2.9.1";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/open-goal/launcher/releases/download/v${finalAttrs.version}/OpenGOAL-Launcher_${finalAttrs.version}_amd64.AppImage";
|
||||
hash = "sha256-McdifSYCHmCTkbmAlSBYlsJwjNTSdinMnMoETi6g4C8=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
dwarfs
|
||||
copyDesktopItems
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
dontPatchELF = true;
|
||||
dontStrip = true;
|
||||
dontPatchShebangs = true;
|
||||
dontAutoPatchelf = true;
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "opengoal-launcher";
|
||||
exec = "opengoal-launcher";
|
||||
icon = "opengoal-launcher";
|
||||
desktopName = "OpenGOAL Launcher";
|
||||
comment = "Launcher for OpenGOAL - native PC port of Jak and Daxter";
|
||||
categories = [ "Game" ];
|
||||
})
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# Extract the DwarFS AppImage
|
||||
mkdir -p extracted
|
||||
dwarfsextract \
|
||||
-i ${finalAttrs.src} \
|
||||
-o extracted \
|
||||
--image-offset 1454544
|
||||
|
||||
# Remove dangling symlinks from bundled AppImage
|
||||
find extracted -xtype l -delete
|
||||
|
||||
# Install the self-contained binary and its bundled libs
|
||||
mkdir -p $out/opt/opengoal-launcher
|
||||
cp -r extracted/. $out/opt/opengoal-launcher/
|
||||
|
||||
chmod +x $out/opt/opengoal-launcher/bin/OpenGOAL-Launcher
|
||||
chmod +x $out/opt/opengoal-launcher/sharun
|
||||
chmod +x $out/opt/opengoal-launcher/AppRun
|
||||
|
||||
mkdir -p $out/bin
|
||||
|
||||
# opengoal-patch-bins: run after the launcher downloads a new version
|
||||
# Uses a quoted heredoc ('EOF') so that $@ and other shell vars are
|
||||
# written literally into the generated script rather than expanded now
|
||||
cat > $out/bin/opengoal-patch-bins << 'PATCHSCRIPT'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
VERSIONS_DIR="$1"
|
||||
|
||||
if [ -z "$VERSIONS_DIR" ]; then
|
||||
echo "Usage: opengoal-patch-bins <path-to-version-dir>"
|
||||
echo "Example: opengoal-patch-bins /path/to/opengoal/versions/official/v0.3.1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LINKER="GLIBC_LIB/ld-linux-x86-64.so.2"
|
||||
RPATH="GLIBC_LIB:ZLIB_LIB"
|
||||
STEAM_RUN="STEAM_RUN_BIN"
|
||||
PATCHELF="PATCHELF_BIN"
|
||||
|
||||
for bin in gk extractor goalc; do
|
||||
if [ -f "$VERSIONS_DIR/$bin" ]; then
|
||||
# Skip if already patched
|
||||
if [ -f "$VERSIONS_DIR/$bin.real" ]; then
|
||||
echo "Skipping $bin (already patched)"
|
||||
continue
|
||||
fi
|
||||
echo "Patching $bin..."
|
||||
"$PATCHELF" \
|
||||
--set-interpreter "$LINKER" \
|
||||
--set-rpath "$RPATH" \
|
||||
"$VERSIONS_DIR/$bin"
|
||||
mv "$VERSIONS_DIR/$bin" "$VERSIONS_DIR/$bin.real"
|
||||
printf '#!/bin/sh\nexec "%s" "%s" "$@"\n' \
|
||||
"$STEAM_RUN" \
|
||||
"$VERSIONS_DIR/$bin.real" \
|
||||
> "$VERSIONS_DIR/$bin"
|
||||
chmod +x "$VERSIONS_DIR/$bin"
|
||||
echo "Done: $bin"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All binaries patched. You can now launch games via the OpenGOAL Launcher."
|
||||
PATCHSCRIPT
|
||||
|
||||
# Replace the placeholders with actual nix store paths
|
||||
substituteInPlace $out/bin/opengoal-patch-bins \
|
||||
--replace "GLIBC_LIB" "${glibc}/lib" \
|
||||
--replace "ZLIB_LIB" "${zlib}/lib" \
|
||||
--replace "STEAM_RUN_BIN" "${steam-run}/bin/steam-run" \
|
||||
--replace "PATCHELF_BIN" "${patchelf}/bin/patchelf"
|
||||
|
||||
chmod +x $out/bin/opengoal-patch-bins
|
||||
|
||||
# Main launcher wrapper - clean PATH, no leaked build tools
|
||||
makeWrapper $out/opt/opengoal-launcher/AppRun $out/bin/opengoal-launcher \
|
||||
--set APPDIR $out/opt/opengoal-launcher \
|
||||
--prefix PATH : $out/opt/opengoal-launcher/bin
|
||||
|
||||
# Install icon
|
||||
mkdir -p $out/share/icons/hicolor/256x256/apps
|
||||
cp extracted/OpenGOAL-Launcher.png \
|
||||
$out/share/icons/hicolor/256x256/apps/opengoal-launcher.png
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Launcher for OpenGOAL, a native PC port of the Jak and Daxter series";
|
||||
longDescription = ''
|
||||
OpenGOAL is a project to decompile and recompile the Jak and Daxter series
|
||||
of games for modern PC hardware. This launcher simplifies the installation,
|
||||
configuration, and update process for OpenGOAL games.
|
||||
|
||||
Note: After the launcher downloads a new game version, run
|
||||
opengoal-patch-bins <path-to-version-dir> to patch the game binaries
|
||||
for NixOS compatibility. Example:
|
||||
opengoal-patch-bins /path/to/opengoal/versions/official/v0.3.1
|
||||
'';
|
||||
homepage = "https://opengoal.dev";
|
||||
downloadPage = "https://github.com/open-goal/launcher/releases";
|
||||
changelog = "https://github.com/open-goal/launcher/releases/tag/v${finalAttrs.version}";
|
||||
license = lib.licenses.isc;
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
};
|
||||
})
|
||||
Reference in New Issue
Block a user