1 { lib, stdenv, fetchzip, cmake, pkg-config
2 , SDL2, libpng, zlib, xz, freetype, fontconfig
3 , nlohmann_json, curl, icu, harfbuzz, expat, glib, pcre2
4 , withOpenGFX ? true, withOpenSFX ? true, withOpenMSX ? true
5 , withFluidSynth ? true, audioDriver ? "alsa"
6 , fluidsynth, soundfont-fluid, libsndfile
7 , flac, libogg, libvorbis, libopus, libmpg123, pulseaudio, alsa-lib, libjack2
8 , procps, writeScriptBin, makeWrapper, runtimeShell }:
12 url = "https://cdn.openttd.org/opengfx-releases/7.1/opengfx-7.1-all.zip";
13 sha256 = "sha256-daJ/Qwg/okpmLQkXcCjruIiP8GEwyyp02YWcGQepxzs=";
17 url = "https://cdn.openttd.org/opensfx-releases/1.0.3/opensfx-1.0.3-all.zip";
18 sha256 = "sha256-QmfXizrRTu/fUcVOY7tCndv4t4BVW+fb0yUi8LgSYzM=";
22 url = "https://cdn.openttd.org/openmsx-releases/0.4.2/openmsx-0.4.2-all.zip";
23 sha256 = "sha256-Cgrg2m+uTODFg39mKgX+hE8atV7v5bVyZd716vSZB8M=";
26 playmidi = writeScriptBin "playmidi" ''
28 trap "${procps}/bin/pkill fluidsynth" EXIT
29 ${fluidsynth}/bin/fluidsynth -a ${audioDriver} -i ${soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2 $*
33 stdenv.mkDerivation rec {
38 url = "https://cdn.openttd.org/openttd-releases/${version}/${pname}-${version}-source.tar.xz";
39 hash = "sha256-YT4IE/rJ9pnpeMWKbOra6AbSUwW19RwOKlXkxwoMeKY=";
42 nativeBuildInputs = [ cmake pkg-config makeWrapper ];
44 SDL2 libpng xz zlib freetype fontconfig
45 nlohmann_json curl icu harfbuzz expat glib pcre2
46 ] ++ lib.optionals withFluidSynth [
47 fluidsynth soundfont-fluid libsndfile
48 flac libogg libvorbis libopus libmpg123 pulseaudio alsa-lib libjack2
51 prefixKey = "--prefix-dir=";
58 ${lib.optionalString withOpenGFX ''
59 cp ${opengfx}/*.tar $out/share/games/openttd/baseset
62 mkdir -p $out/share/games/openttd/data
64 ${lib.optionalString withOpenSFX ''
65 cp ${opensfx}/*.tar $out/share/games/openttd/data
68 mkdir $out/share/games/openttd/baseset/openmsx
70 ${lib.optionalString withOpenMSX ''
71 cp ${openmsx}/*.tar $out/share/games/openttd/baseset/openmsx
74 ${lib.optionalString withFluidSynth ''
75 wrapProgram $out/bin/openttd \
77 --add-flags extmidi:cmd=${playmidi}/bin/playmidi
82 description = ''Open source clone of the Microprose game "Transport Tycoon Deluxe"'';
83 mainProgram = "openttd";
85 OpenTTD is a transportation economics simulator. In single player mode,
86 players control a transportation business, and use rail, road, sea, and air
87 transport to move goods and people around the simulated world.
89 In multiplayer networked mode, players may:
90 - play competitively as different businesses
91 - play cooperatively controlling the same business
92 - observe as spectators
94 homepage = "https://www.openttd.org/";
95 changelog = "https://cdn.openttd.org/openttd-releases/${version}/changelog.txt";
96 license = licenses.gpl2Only;
97 platforms = platforms.linux;
98 maintainers = with maintainers; [ jcumming fpletz ];