2021-09-30 19:02:48 +00:00
|
|
|
{ lib
|
|
|
|
, fetchzip
|
|
|
|
, libXxf86vm
|
|
|
|
, makeWrapper
|
2022-07-09 13:20:14 +00:00
|
|
|
, openal
|
2021-09-30 19:02:48 +00:00
|
|
|
, openjdk
|
|
|
|
, stdenv
|
|
|
|
, xorg
|
2021-10-07 18:09:52 +00:00
|
|
|
, copyDesktopItems
|
|
|
|
, makeDesktopItem
|
2022-07-09 13:20:14 +00:00
|
|
|
, writeScript
|
2021-09-30 19:02:48 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "starsector";
|
2023-05-09 21:12:40 +00:00
|
|
|
version = "0.96a-RC8";
|
2021-09-30 19:02:48 +00:00
|
|
|
|
|
|
|
src = fetchzip {
|
|
|
|
url = "https://s3.amazonaws.com/fractalsoftworks/starsector/starsector_linux-${version}.zip";
|
2023-05-09 21:12:40 +00:00
|
|
|
sha256 = "sha256-RDXqFqiWpBG3kasofzbOl7Zp0a9LiMpJKsHcFaJtm2Y=";
|
2021-09-30 19:02:48 +00:00
|
|
|
};
|
|
|
|
|
2022-07-09 13:20:14 +00:00
|
|
|
nativeBuildInputs = [ copyDesktopItems makeWrapper ];
|
|
|
|
buildInputs = [ xorg.libXxf86vm openal ];
|
2021-09-30 19:02:48 +00:00
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
2021-10-07 18:09:52 +00:00
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "starsector";
|
|
|
|
exec = "starsector";
|
|
|
|
icon = "starsector";
|
|
|
|
comment = meta.description;
|
|
|
|
genericName = "starsector";
|
|
|
|
desktopName = "Starsector";
|
2022-02-22 14:56:15 +00:00
|
|
|
categories = [ "Game" ];
|
2021-10-07 18:09:52 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-09-30 19:02:48 +00:00
|
|
|
# need to cd into $out in order for classpath to pick up correct jar files
|
|
|
|
installPhase = ''
|
2021-10-07 18:09:52 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2022-11-25 08:58:37 +00:00
|
|
|
mkdir -p $out/bin $out/share/starsector
|
2022-07-09 13:20:14 +00:00
|
|
|
rm -r jre_linux # remove bundled jre7
|
2021-09-30 19:02:48 +00:00
|
|
|
rm starfarer.api.zip
|
2022-11-25 08:58:37 +00:00
|
|
|
cp -r ./* $out/share/starsector
|
2021-09-30 19:02:48 +00:00
|
|
|
|
2021-10-07 18:09:52 +00:00
|
|
|
mkdir -p $out/share/icons/hicolor/64x64/apps
|
|
|
|
ln -s $out/graphics/ui/s_icon64.png $out/share/icons/hicolor/64x64/apps/starsector.png
|
|
|
|
|
2022-11-25 08:58:37 +00:00
|
|
|
wrapProgram $out/share/starsector/starsector.sh \
|
2021-09-30 19:02:48 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ openjdk ]} \
|
|
|
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \
|
2022-03-14 18:06:00 +00:00
|
|
|
--run 'mkdir -p ''${XDG_DATA_HOME:-~/.local/share}/starsector' \
|
2022-11-25 08:58:37 +00:00
|
|
|
--chdir "$out/share/starsector"
|
|
|
|
ln -s $out/share/starsector/starsector.sh $out/bin/starsector
|
2021-10-07 18:09:52 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2021-09-30 19:02:48 +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
|
2022-07-09 13:20:14 +00:00
|
|
|
# additionally, add some GC options to improve performance of the game
|
2021-09-30 19:02:48 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace starsector.sh \
|
|
|
|
--replace "./jre_linux/bin/java" "${openjdk}/bin/java" \
|
2022-11-25 08:58:37 +00:00
|
|
|
--replace "./native/linux" "$out/share/starsector/native/linux" \
|
2022-07-09 13:20:14 +00:00
|
|
|
--replace "=." "=\''${XDG_DATA_HOME:-\$HOME/.local/share}/starsector" \
|
|
|
|
--replace "-XX:+CompilerThreadHintNoPreempt" "-XX:+UnlockDiagnosticVMOptions -XX:-BytecodeVerificationRemote -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSConcurrentMTEnabled -XX:+DisableExplicitGC"
|
2021-09-30 19:02:48 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Open-world single-player space-combat, roleplaying, exploration, and economic game";
|
|
|
|
homepage = "https://fractalsoftworks.com";
|
2022-06-02 13:38:41 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
2021-09-30 19:02:48 +00:00
|
|
|
license = licenses.unfree;
|
|
|
|
maintainers = with maintainers; [ bbigras ];
|
|
|
|
};
|
2022-07-09 13:20:14 +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;
|
|
|
|
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
|
|
|
|
'';
|
2021-09-30 19:02:48 +00:00
|
|
|
}
|