From 6c8d7891746e9627c4518c5bd0b3c0077d85ba05 Mon Sep 17 00:00:00 2001 From: Anton Bulakh Date: Sat, 9 Jul 2022 16:20:14 +0300 Subject: [PATCH] starsector: fix jvm compatibility, startup crashes and sound, add passthru.updateScript --- pkgs/games/starsector/default.nix | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pkgs/games/starsector/default.nix b/pkgs/games/starsector/default.nix index e929ef98fbf..bbc781d6ab2 100644 --- a/pkgs/games/starsector/default.nix +++ b/pkgs/games/starsector/default.nix @@ -1,32 +1,27 @@ { lib -, alsa-lib , fetchzip , libXxf86vm , makeWrapper +, openal , openjdk , stdenv , xorg , copyDesktopItems , makeDesktopItem +, writeScript }: stdenv.mkDerivation rec { pname = "starsector"; - version = "0.95.1a-RC5"; + version = "0.95.1a-RC6"; src = fetchzip { url = "https://s3.amazonaws.com/fractalsoftworks/starsector/starsector_linux-${version}.zip"; - sha256 = "sha256-V8/WQPvPIrF3Tg7JVO+GfeYqWhkWWrnHSVcFXGQqDAA="; + sha256 = "sha256-+0zGJHM+SMonx3sytCQNQA/QBgzdPMEfQvOjrCDSOs8="; }; - nativeBuildInputs = [ - copyDesktopItems - makeWrapper - ]; - buildInputs = with xorg; [ - alsa-lib - libXxf86vm - ]; + nativeBuildInputs = [ copyDesktopItems makeWrapper ]; + buildInputs = [ xorg.libXxf86vm openal ]; dontBuild = true; @@ -47,7 +42,7 @@ stdenv.mkDerivation rec { runHook preInstall mkdir -p $out/bin - rm -r jre_linux # remove jre7 + rm -r jre_linux # remove bundled jre7 rm starfarer.api.zip cp -r ./* $out @@ -66,10 +61,13 @@ stdenv.mkDerivation rec { # it tries to run everything with relative paths, which makes it CWD dependent # also point mod, screenshot, and save directory to $XDG_DATA_HOME + # additionally, add some GC options to improve performance of the game postPatch = '' substituteInPlace starsector.sh \ --replace "./jre_linux/bin/java" "${openjdk}/bin/java" \ - --replace "./native/linux" "$out/native/linux" + --replace "./native/linux" "$out/native/linux" \ + --replace "=." "=\''${XDG_DATA_HOME:-\$HOME/.local/share}/starsector" \ + --replace "-XX:+CompilerThreadHintNoPreempt" "-XX:+UnlockDiagnosticVMOptions -XX:-BytecodeVerificationRemote -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSConcurrentMTEnabled -XX:+DisableExplicitGC" ''; meta = with lib; { @@ -79,4 +77,12 @@ stdenv.mkDerivation rec { license = licenses.unfree; maintainers = with maintainers; [ bbigras ]; }; + + passthru.updateScript = writeScript "starsector-update-script" '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p curl gnugrep common-updater-scripts + set -eou pipefail; + version=$(curl -s https://fractalsoftworks.com/preorder/ | grep -oP "https://s3.amazonaws.com/fractalsoftworks/starsector/starsector_linux-\K.*?(?=\.zip)" | head -1) + update-source-version ${pname} "$version" --file=./pkgs/games/starsector/default.nix + ''; }