@@ -0,0 +1,73 @@
1+{ lib
2+, stdenv
3+, fetchFromGitHub
4+, pkg-config
5+, coreutils
6+, portaudio
7+, libbsd
8+, libpng
9+, libvorbis
10+, SDL2
11+, makeWrapper
12+, lua5_2
13+, glew
14+, openssl
15+, picotts
16+, alsa-utils
17+, espeak-classic
18+, sox
19+, libopus
20+, openscad
21+}:
22+
23+stdenv.mkDerivation {
24+ pname = "snis_launcher";
25+ version = "unstable-2021-10-17";
26+
27+ src = fetchFromGitHub {
28+ owner = "smcameron";
29+ repo = "space-nerds-in-space";
30+ rev = "e70d3c63e33c940feb53c8d818ce2d8ea2aadf00";
31+ sha256 = "sha256-HVCb1iFn7GWNpedtFCgLyd0It8s4PEmUwDfb8ap1TDc=";
32+ };
33+
34+ postPatch = ''
35+ substituteInPlace Makefile \
36+ --replace "OPUSARCHIVE=libopus.a" "OPUSARCHIVE=" \
37+ --replace "-I./opus-1.3.1/include" "-I${libopus.dev}/include/opus"
38+ substituteInPlace snis_launcher \
39+ --replace "PREFIX=." "PREFIX=$out"
40+ substituteInPlace snis_text_to_speech.sh \
41+ --replace "pico2wave" "${sox}/bin/pico2wave" \
42+ --replace "espeak" "${espeak-classic}/bin/espeak" \
43+ --replace "play" "${sox}/bin/play" \
44+ --replace "aplay" "${alsa-utils}/bin/aplay" \
45+ --replace "/bin/rm" "${coreutils}/bin/rm"
46+ '';
47+
48+ nativeBuildInputs = [ pkg-config openscad makeWrapper ];
49+ buildInputs = [ coreutils portaudio libbsd libpng libvorbis SDL2 lua5_2 glew openssl picotts sox alsa-utils libopus ];
50+
51+ postBuild = ''
52+ make models -j$NIX_BUILD_CORES
53+ '';
54+
55+ installPhase = ''
56+ runHook preInstall
57+ mkdir -p $out
58+ cp -R share $out/share
59+ cp -R bin $out/bin
60+ cp snis_launcher $out/bin/
61+ # without this, snis_client crashes on Wayland
62+ wrapProgram $out/bin/snis_client --set SDL_VIDEODRIVER x11
63+ runHook postInstall
64+ '';
65+
66+ meta = with lib; {
67+ description = "Space Nerds In Space, a multi-player spaceship bridge simulator";
68+ homepage = "https://smcameron.github.io/space-nerds-in-space/";
69+ license = licenses.gpl2;
70+ maintainers = with maintainers; [ alyaeanyx ];
71+ platforms = platforms.linux;
72+ };
73+}