Merge pull request #181422 from necauqua/starsector-fixes

starsector: fix jvm compatibility, startup crashes and sound, add passthru.updateScript
This commit is contained in:
Ryan Burns 2022-11-19 00:11:08 -08:00 committed by GitHub
commit 2e065b0073
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,32 +1,27 @@
{ lib { lib
, alsa-lib
, fetchzip , fetchzip
, libXxf86vm , libXxf86vm
, makeWrapper , makeWrapper
, openal
, openjdk , openjdk
, stdenv , stdenv
, xorg , xorg
, copyDesktopItems , copyDesktopItems
, makeDesktopItem , makeDesktopItem
, writeScript
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "starsector"; pname = "starsector";
version = "0.95.1a-RC5"; version = "0.95.1a-RC6";
src = fetchzip { src = fetchzip {
url = "https://s3.amazonaws.com/fractalsoftworks/starsector/starsector_linux-${version}.zip"; url = "https://s3.amazonaws.com/fractalsoftworks/starsector/starsector_linux-${version}.zip";
sha256 = "sha256-V8/WQPvPIrF3Tg7JVO+GfeYqWhkWWrnHSVcFXGQqDAA="; sha256 = "sha256-+0zGJHM+SMonx3sytCQNQA/QBgzdPMEfQvOjrCDSOs8=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [ copyDesktopItems makeWrapper ];
copyDesktopItems buildInputs = [ xorg.libXxf86vm openal ];
makeWrapper
];
buildInputs = with xorg; [
alsa-lib
libXxf86vm
];
dontBuild = true; dontBuild = true;
@ -47,7 +42,7 @@ stdenv.mkDerivation rec {
runHook preInstall runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
rm -r jre_linux # remove jre7 rm -r jre_linux # remove bundled jre7
rm starfarer.api.zip rm starfarer.api.zip
cp -r ./* $out cp -r ./* $out
@ -66,10 +61,13 @@ stdenv.mkDerivation rec {
# it tries to run everything with relative paths, which makes it CWD dependent # it tries to run everything with relative paths, which makes it CWD dependent
# also point mod, screenshot, and save directory to $XDG_DATA_HOME # also point mod, screenshot, and save directory to $XDG_DATA_HOME
# additionally, add some GC options to improve performance of the game
postPatch = '' postPatch = ''
substituteInPlace starsector.sh \ substituteInPlace starsector.sh \
--replace "./jre_linux/bin/java" "${openjdk}/bin/java" \ --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; { meta = with lib; {
@ -79,4 +77,12 @@ stdenv.mkDerivation rec {
license = licenses.unfree; license = licenses.unfree;
maintainers = with maintainers; [ bbigras ]; 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
'';
} }