Merge pull request #17855 from womfoo/fix/openttd-music-support

openttd: music support

authored by Nikolay Amiantov and committed by GitHub 392fb9d0 b7b2019e

+20 -3
+20 -3
pkgs/games/openttd/default.nix
··· 1 1 { stdenv, fetchurl, fetchzip, pkgconfig, SDL, libpng, zlib, xz, freetype, fontconfig 2 2 , withOpenGFX ? true, withOpenSFX ? true, withOpenMSX ? true 3 + , withFluidSynth ? true, audioDriver ? "alsa", fluidsynth, soundfont-fluid, procps 4 + , writeScriptBin, makeWrapper 3 5 }: 4 6 5 7 let ··· 18 20 sha256 = "0qnmfzz0v8vxrrvxnm7szphrlrlvhkwn3y92b4iy0b4b6yam0yd4"; 19 21 }; 20 22 23 + playmidi = writeScriptBin "playmidi" '' 24 + #!/bin/sh 25 + trap "${procps}/bin/pkill fluidsynth" EXIT 26 + ${fluidsynth}/bin/fluidsynth -a ${audioDriver} -i ${soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2 $* 27 + ''; 28 + 21 29 in 22 30 stdenv.mkDerivation rec { 23 31 name = "openttd-${version}"; ··· 28 36 sha256 = "1ak32fj5xkk2fvmm3g8i7wzmk4bh2ijsp8fzvvw5wj6365p9j24v"; 29 37 }; 30 38 31 - nativeBuildInputs = [ pkgconfig ]; 32 - buildInputs = [ SDL libpng xz zlib freetype fontconfig ]; 39 + nativeBuildInputs = [ pkgconfig makeWrapper ]; 40 + buildInputs = [ SDL libpng xz zlib freetype fontconfig ] 41 + ++ stdenv.lib.optional withFluidSynth [ fluidsynth soundfont-fluid ]; 33 42 34 43 prefixKey = "--prefix-dir="; 35 44 ··· 52 61 cp ${opensfx}/*.{obs,cat} $out/share/games/openttd/data 53 62 ''} 54 63 64 + mkdir $out/share/games/openttd/baseset/openmsx 65 + 55 66 ${stdenv.lib.optionalString withOpenMSX '' 56 - cp ${openmsx}/*.{obm,mid} $out/share/games/openttd/data 67 + cp ${openmsx}/*.{obm,mid} $out/share/games/openttd/baseset/openmsx 68 + ''} 69 + 70 + ${stdenv.lib.optionalString withFluidSynth '' 71 + wrapProgram $out/bin/openttd \ 72 + --add-flags -m \ 73 + --add-flags extmidi:cmd=${playmidi}/bin/playmidi 57 74 ''} 58 75 ''; 59 76