From 9a680ec3c0dffdb7cb0cc59beb2c60070374a9b0 Mon Sep 17 00:00:00 2001 From: brian Date: Sun, 19 Apr 2026 09:16:46 -0400 Subject: [PATCH] working --- default.nix | 2 + package.nix | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++ result | 1 + 3 files changed, 160 insertions(+) create mode 100644 default.nix create mode 100644 package.nix create mode 120000 result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..50a509b --- /dev/null +++ b/default.nix @@ -0,0 +1,2 @@ +with import { config.allowUnfree = true; }; +callPackage ./package.nix {} \ No newline at end of file diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..d45728d --- /dev/null +++ b/package.nix @@ -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 " + 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 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 ]; + }; +}) \ No newline at end of file diff --git a/result b/result new file mode 120000 index 0000000..6f50428 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/rcywa2yb7h57rbn3mcyw6yxxh42bjqpn-opengoal-launcher-2.9.1 \ No newline at end of file