Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 165 lines 4.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchzip, 5 fetchpatch, 6 cmake, 7 pkg-config, 8 SDL2, 9 libpng, 10 zlib, 11 xz, 12 freetype, 13 fontconfig, 14 curl, 15 icu, 16 harfbuzz, 17 expat, 18 glib, 19 pcre2, 20 withOpenGFX ? true, 21 withOpenSFX ? true, 22 withOpenMSX ? true, 23 withFluidSynth ? true, 24 fluidsynth, 25 soundfont-fluid, 26 soundfont-name ? "FluidR3_GM2-2", 27 libsndfile, 28 flac, 29 libogg, 30 libvorbis, 31 libopus, 32 libmpg123, 33 pulseaudio, 34 alsa-lib, 35 libjack2, 36 makeWrapper, 37 buildPackages, 38}: 39 40let 41 opengfx = fetchzip { 42 url = "https://cdn.openttd.org/opengfx-releases/7.1/opengfx-7.1-all.zip"; 43 hash = "sha256-daJ/Qwg/okpmLQkXcCjruIiP8GEwyyp02YWcGQepxzs="; 44 }; 45 46 opensfx = fetchzip { 47 url = "https://cdn.openttd.org/opensfx-releases/1.0.3/opensfx-1.0.3-all.zip"; 48 hash = "sha256-QmfXizrRTu/fUcVOY7tCndv4t4BVW+fb0yUi8LgSYzM="; 49 }; 50 51 openmsx = fetchzip { 52 url = "https://cdn.openttd.org/openmsx-releases/0.4.2/openmsx-0.4.2-all.zip"; 53 hash = "sha256-Cgrg2m+uTODFg39mKgX+hE8atV7v5bVyZd716vSZB8M="; 54 }; 55 56 # OpenTTD builds and uses some of its own tools during the build and we need those to be available for cross-compilation. 57 # Build the tools for buildPlatform with minimal dependencies, using the "OPTION_TOOLS_ONLY" flag. 58 crossTools = buildPackages.openttd.overrideAttrs (oldAttrs: { 59 pname = "openttd-tools"; 60 buildInputs = [ ]; 61 cmakeFlags = oldAttrs.cmakeFlags or [ ] ++ [ (lib.cmakeBool "OPTION_TOOLS_ONLY" true) ]; 62 installPhase = '' 63 install -Dm555 src/strgen/strgen -t $out/bin 64 install -Dm555 src/settingsgen/settingsgen -t $out/bin 65 ''; 66 }); 67in 68stdenv.mkDerivation (finalAttrs: { 69 pname = "openttd"; 70 version = "14.1"; 71 72 src = fetchzip { 73 url = "https://cdn.openttd.org/openttd-releases/${finalAttrs.version}/openttd-${finalAttrs.version}-source.tar.xz"; 74 hash = "sha256-YT4IE/rJ9pnpeMWKbOra6AbSUwW19RwOKlXkxwoMeKY="; 75 }; 76 77 patches = [ 78 # Fix build against icu-76: 79 # https://github.com/OpenTTD/OpenTTD/pull/13048 80 (fetchpatch { 81 name = "icu-75.patch"; 82 url = "https://github.com/OpenTTD/OpenTTD/commit/14fac2ad37bfb9cec56b4f9169d864f6f1c7b96e.patch"; 83 hash = "sha256-L35ybnTKPO+HVP/7ZYzWM2mA+s1RAywhofSuzpy/6sc="; 84 }) 85 ]; 86 87 nativeBuildInputs = [ 88 cmake 89 pkg-config 90 makeWrapper 91 ] 92 ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 93 crossTools 94 ]; 95 96 buildInputs = [ 97 SDL2 98 libpng 99 xz 100 zlib 101 freetype 102 fontconfig 103 curl 104 icu 105 harfbuzz 106 expat 107 glib 108 pcre2 109 ] 110 ++ lib.optionals withFluidSynth [ 111 fluidsynth 112 soundfont-fluid 113 libsndfile 114 flac 115 libogg 116 libvorbis 117 libopus 118 libmpg123 119 pulseaudio 120 alsa-lib 121 libjack2 122 ]; 123 124 strictDeps = true; 125 126 postPatch = '' 127 substituteInPlace src/music/fluidsynth.cpp \ 128 --replace-fail "/usr/share/soundfonts/default.sf2" \ 129 "${soundfont-fluid}/share/soundfonts/${soundfont-name}.sf2" 130 ''; 131 132 postInstall = 133 lib.optionalString withOpenGFX '' 134 cp ${opengfx}/*.tar $out/share/games/openttd/baseset 135 '' 136 + lib.optionalString withOpenSFX '' 137 cp ${opensfx}/*.tar $out/share/games/openttd/baseset 138 '' 139 + lib.optionalString withOpenMSX '' 140 tar -xf ${openmsx}/*.tar -C $out/share/games/openttd/baseset 141 ''; 142 143 meta = { 144 description = ''Open source clone of the Microprose game "Transport Tycoon Deluxe"''; 145 mainProgram = "openttd"; 146 longDescription = '' 147 OpenTTD is a transportation economics simulator. In single player mode, 148 players control a transportation business, and use rail, road, sea, and air 149 transport to move goods and people around the simulated world. 150 151 In multiplayer networked mode, players may: 152 - play competitively as different businesses 153 - play cooperatively controlling the same business 154 - observe as spectators 155 ''; 156 homepage = "https://www.openttd.org/"; 157 changelog = "https://cdn.openttd.org/openttd-releases/${finalAttrs.version}/changelog.txt"; 158 license = lib.licenses.gpl2Only; 159 platforms = lib.platforms.linux; 160 maintainers = with lib.maintainers; [ 161 jcumming 162 fpletz 163 ]; 164 }; 165})