14 stdenv.mkDerivation rec {
16 version = "0.97a-RC11";
19 url = "https://f005.backblazeb2.com/file/fractalsoftworks/release/starsector_linux-${version}.zip";
20 sha256 = "sha256-KT4n0kBocaljD6dTbpr6xcwy6rBBZTFjov9m+jizDW4=";
23 nativeBuildInputs = [ copyDesktopItems makeWrapper ];
24 buildInputs = [ xorg.libXxf86vm openal libGL ];
33 comment = meta.description;
34 genericName = "starsector";
35 desktopName = "Starsector";
36 categories = [ "Game" ];
40 # need to cd into $out in order for classpath to pick up correct jar files
44 mkdir -p $out/bin $out/share/starsector
45 rm -r jre_linux # remove bundled jre7
47 cp -r ./* $out/share/starsector
49 mkdir -p $out/share/icons/hicolor/64x64/apps
50 ln -s $out/share/starsector/graphics/ui/s_icon64.png \
51 $out/share/icons/hicolor/64x64/apps/starsector.png
53 wrapProgram $out/share/starsector/starsector.sh \
54 --prefix PATH : ${lib.makeBinPath [ openjdk xorg.xrandr ]} \
55 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \
56 --run 'mkdir -p ''${XDG_DATA_HOME:-~/.local/share}/starsector' \
57 --chdir "$out/share/starsector"
58 ln -s $out/share/starsector/starsector.sh $out/bin/starsector
63 # it tries to run everything with relative paths, which makes it CWD dependent
64 # also point mod, screenshot, and save directory to $XDG_DATA_HOME
65 # additionally, add some GC options to improve performance of the game,
66 # remove flags "PermSize" and "MaxPermSize" that were removed with Java 8 and
67 # pass-through CLI args ($@) to the JVM.
69 substituteInPlace starsector.sh \
70 --replace-fail "./jre_linux/bin/java" "${openjdk}/bin/java" \
71 --replace-fail "./native/linux" "$out/share/starsector/native/linux" \
72 --replace-fail "=." "=\''${XDG_DATA_HOME:-\$HOME/.local/share}/starsector" \
73 --replace-fail "-XX:+CompilerThreadHintNoPreempt" "-XX:+UnlockDiagnosticVMOptions -XX:-BytecodeVerificationRemote -XX:+CMSConcurrentMTEnabled -XX:+DisableExplicitGC" \
74 --replace-quiet " -XX:PermSize=192m -XX:MaxPermSize=192m" "" \
75 --replace-fail "com.fs.starfarer.StarfarerLauncher" "\"\$@\" com.fs.starfarer.StarfarerLauncher"
78 passthru.updateScript = writeScript "starsector-update-script" ''
79 #!/usr/bin/env nix-shell
80 #!nix-shell -i bash -p curl gnugrep common-updater-scripts
82 version=$(curl -s https://fractalsoftworks.com/preorder/ | grep -oP "https://f005.backblazeb2.com/file/fractalsoftworks/release/starsector_linux-\K.*?(?=\.zip)" | head -1)
83 update-source-version ${pname} "$version" --file=./pkgs/games/starsector/default.nix
87 description = "Open-world single-player space-combat, roleplaying, exploration, and economic game";
88 homepage = "https://fractalsoftworks.com";
89 sourceProvenance = with sourceTypes; [ binaryBytecode ];
90 license = licenses.unfree;
91 maintainers = with maintainers; [ bbigras rafaelrc ];