2021-10-06 13:57:05 +00:00
|
|
|
{ lib
|
|
|
|
, fetchzip
|
2024-01-02 11:29:13 +00:00
|
|
|
, libGL
|
2021-10-06 13:57:05 +00:00
|
|
|
, makeWrapper
|
2022-11-21 17:40:18 +00:00
|
|
|
, openal
|
2021-10-06 13:57:05 +00:00
|
|
|
, openjdk
|
|
|
|
, stdenv
|
|
|
|
, xorg
|
2021-10-08 15:17:17 +00:00
|
|
|
, copyDesktopItems
|
|
|
|
, makeDesktopItem
|
2022-11-21 17:40:18 +00:00
|
|
|
, writeScript
|
2021-10-06 13:57:05 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "starsector";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "0.97a-RC11";
|
2021-10-06 13:57:05 +00:00
|
|
|
|
|
|
|
src = fetchzip {
|
2023-11-16 04:20:00 +00:00
|
|
|
url = "https://f005.backblazeb2.com/file/fractalsoftworks/release/starsector_linux-${version}.zip";
|
2024-02-29 20:09:43 +00:00
|
|
|
sha256 = "sha256-KT4n0kBocaljD6dTbpr6xcwy6rBBZTFjov9m+jizDW4=";
|
2021-10-06 13:57:05 +00:00
|
|
|
};
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
nativeBuildInputs = [ copyDesktopItems makeWrapper ];
|
2024-01-02 11:29:13 +00:00
|
|
|
buildInputs = [ xorg.libXxf86vm openal libGL ];
|
2021-10-06 13:57:05 +00:00
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "starsector";
|
|
|
|
exec = "starsector";
|
|
|
|
icon = "starsector";
|
|
|
|
comment = meta.description;
|
|
|
|
genericName = "starsector";
|
|
|
|
desktopName = "Starsector";
|
2022-03-05 16:20:37 +00:00
|
|
|
categories = [ "Game" ];
|
2021-10-08 15:17:17 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-10-06 13:57:05 +00:00
|
|
|
# need to cd into $out in order for classpath to pick up correct jar files
|
|
|
|
installPhase = ''
|
2021-10-08 15:17:17 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
mkdir -p $out/bin $out/share/starsector
|
2022-11-21 17:40:18 +00:00
|
|
|
rm -r jre_linux # remove bundled jre7
|
2021-10-06 13:57:05 +00:00
|
|
|
rm starfarer.api.zip
|
2022-11-27 09:42:12 +00:00
|
|
|
cp -r ./* $out/share/starsector
|
2021-10-06 13:57:05 +00:00
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
mkdir -p $out/share/icons/hicolor/64x64/apps
|
2024-02-29 20:09:43 +00:00
|
|
|
ln -s $out/share/starsector/graphics/ui/s_icon64.png \
|
|
|
|
$out/share/icons/hicolor/64x64/apps/starsector.png
|
2021-10-08 15:17:17 +00:00
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
wrapProgram $out/share/starsector/starsector.sh \
|
2024-01-25 14:12:00 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ openjdk xorg.xrandr ]} \
|
2021-10-06 13:57:05 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \
|
2022-04-27 09:35:20 +00:00
|
|
|
--run 'mkdir -p ''${XDG_DATA_HOME:-~/.local/share}/starsector' \
|
2022-11-27 09:42:12 +00:00
|
|
|
--chdir "$out/share/starsector"
|
|
|
|
ln -s $out/share/starsector/starsector.sh $out/bin/starsector
|
2021-10-08 15:17:17 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2021-10-06 13:57:05 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# it tries to run everything with relative paths, which makes it CWD dependent
|
|
|
|
# also point mod, screenshot, and save directory to $XDG_DATA_HOME
|
2024-05-15 15:35:15 +00:00
|
|
|
# additionally, add some GC options to improve performance of the game,
|
|
|
|
# remove flags "PermSize" and "MaxPermSize" that were removed with Java 8 and
|
|
|
|
# pass-through CLI args ($@) to the JVM.
|
2021-10-06 13:57:05 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace starsector.sh \
|
2024-02-29 20:09:43 +00:00
|
|
|
--replace-fail "./jre_linux/bin/java" "${openjdk}/bin/java" \
|
|
|
|
--replace-fail "./native/linux" "$out/share/starsector/native/linux" \
|
|
|
|
--replace-fail "=." "=\''${XDG_DATA_HOME:-\$HOME/.local/share}/starsector" \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace-fail "-XX:+CompilerThreadHintNoPreempt" "-XX:+UnlockDiagnosticVMOptions -XX:-BytecodeVerificationRemote -XX:+CMSConcurrentMTEnabled -XX:+DisableExplicitGC" \
|
|
|
|
--replace-quiet " -XX:PermSize=192m -XX:MaxPermSize=192m" "" \
|
|
|
|
--replace-fail "com.fs.starfarer.StarfarerLauncher" "\"\$@\" com.fs.starfarer.StarfarerLauncher"
|
2021-10-06 13:57:05 +00:00
|
|
|
'';
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
passthru.updateScript = writeScript "starsector-update-script" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl gnugrep common-updater-scripts
|
|
|
|
set -eou pipefail;
|
2023-11-16 04:20:00 +00:00
|
|
|
version=$(curl -s https://fractalsoftworks.com/preorder/ | grep -oP "https://f005.backblazeb2.com/file/fractalsoftworks/release/starsector_linux-\K.*?(?=\.zip)" | head -1)
|
2022-11-21 17:40:18 +00:00
|
|
|
update-source-version ${pname} "$version" --file=./pkgs/games/starsector/default.nix
|
|
|
|
'';
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Open-world single-player space-combat, roleplaying, exploration, and economic game";
|
|
|
|
homepage = "https://fractalsoftworks.com";
|
|
|
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
|
|
|
license = licenses.unfree;
|
|
|
|
maintainers = with maintainers; [ bbigras rafaelrc ];
|
|
|
|
};
|
2021-10-06 13:57:05 +00:00
|
|
|
}
|