simutrans: update, refactor, improve, add paksets

Close #7019.

- update all, and add more paksets
- add config.simutrans.paksets, multiple are possible now
- fix #6719: missing sounds
- move user settings from ~/simutrans to ~/.simutrans
- darwin support is untested (but claimed upstream)

Tested-by: Matthias Beyer <mail@beyermatthias.de>
(and by the author vcunat)

+129 -62
+127 -62
pkgs/games/simutrans/default.nix
··· 1 - { stdenv, fetchurl, unzip, zlib, libpng, bzip2, SDL, SDL_mixer, makeWrapper } : 2 3 let 4 - result = withPak (mkPak pak128); 5 6 - ver_1 = "112"; 7 - ver_2 = "3"; 8 - ver_h2 = "${ver_1}-${ver_2}"; 9 10 - # "pakset" of objects, images, text, music, etc. 11 - mkPak = src: stdenv.mkDerivation { 12 - name = "simutrans-pakset"; 13 - inherit src; 14 - unpackPhase = "true"; 15 - buildInputs = [ unzip ]; 16 - installPhase = '' 17 - mkdir -p $out 18 - cd $out 19 - unzip ${src} 20 - mv simutrans/*/* . 21 - rm -rf simutrans 22 - ''; 23 }; 24 - pak64 = fetchurl { 25 - url = "mirror://sourceforge/simutrans/pak64/${ver_h2}/simupak64-${ver_h2}.zip"; 26 - sha256 = "1ng963n2gvnwmsj73iy3gp9i5iqf5g6qk1gh1jnfm86gnjrsrq4m"; 27 }; 28 - pak128 = fetchurl { 29 - url = "mirror://sourceforge/simutrans/pak128/pak128%20for%20${ver_1}/pak128-2.3.0--${ver_1}.2.zip"; 30 - sha256 = "0jcif6mafsvpvxh1njyd6z2f6sab0fclq3f3nlg765yp3i1bfgff"; 31 - }; 32 33 - withPak = pak: stdenv.mkDerivation { 34 inherit (binaries) name; 35 - unpackPhase = "true"; 36 - buildInputs = [ makeWrapper ]; 37 - installPhase = ''makeWrapper "${binaries}/bin/simutrans" "$out/bin/simutrans" --add-flags -objects --add-flags "${pak}"''; 38 - inherit (binaries) meta; 39 }; 40 41 binaries = stdenv.mkDerivation rec { 42 - pname = "simutrans"; 43 - name = "${pname}-${ver_1}.${ver_2}"; 44 45 - src = fetchurl { 46 - url = "mirror://sourceforge/simutrans/simutrans/${ver_h2}/simutrans-src-${ver_h2}.zip"; 47 - sha256 = "0jdq2krfj3qsh8dks9ixsdvpyjq9yi80p58b0xjpsn35mkbxxaca"; 48 - }; 49 50 - # this resource is needed since 112.2 because the folders in simutrans directory has been removed from source code 51 - resources = fetchurl { 52 - url = "mirror://sourceforge/simutrans/simutrans/${ver_h2}/simulinux-${ver_h2}.zip"; 53 - sha256 = "14ly341pdkr8r3cd0q49w424m79iz38iaxfi9l1yfcxl8idkga1c"; 54 - }; 55 sourceRoot = "."; 56 57 - buildInputs = [ zlib libpng bzip2 SDL SDL_mixer unzip ]; 58 - 59 - preConfigure = '' 60 - # Configuration as per the readme.txt 61 - sed \ 62 - -e 's@#BACKEND = sdl@BACKEND = sdl@' \ 63 - -e 's@#COLOUR_DEPTH = 16@COLOUR_DEPTH = 16@' \ 64 - -e 's@#OSTYPE = linux@OSTYPE = linux@' \ 65 - < config.template > config.default 66 67 - # Different default data dir 68 - sed -i -e 's:argv\[0\]:"'$out'/share/simutrans/":' \ 69 - simmain.cc 70 71 - # Use ~/.simutrans instead of ~/simutrans ##not working 72 - #sed -i -e 's@%s/simutrans@%s/.simutrans@' simsys_s.cc 73 74 - # No optimization overriding 75 - sed -i -e '/-O$/d' Makefile 76 ''; 77 78 installPhase = '' 79 mkdir -p $out/share/ 80 mv simutrans $out/share/ 81 - unzip -o ${resources} -d $out/share/ 82 83 mkdir -p $out/bin/ 84 mv build/default/sim $out/bin/simutrans 85 ''; 86 87 - meta = { 88 description = "A simulation game in which the player strives to run a successful transport system"; 89 longDescription = '' 90 Simutrans is a cross-platform simulation game in which the ··· 94 ''; 95 96 homepage = http://www.simutrans.com/; 97 - license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; 98 - maintainers = [ stdenv.lib.maintainers.kkallio ]; 99 - platforms = stdenv.lib.platforms.linux; 100 }; 101 }; 102 103 in result
··· 1 + { stdenv, fetchurl, pkgconfig, unzip, zlib, libpng, bzip2, SDL, SDL_mixer 2 + , buildEnv, config 3 + }: 4 5 let 6 + # Choose your "paksets" of objects, images, text, music, etc. 7 + paksets = config.simutrans.paksets or "pak64 pak128"; 8 9 + result = with stdenv.lib; withPaks ( 10 + if paksets == "*" then attrValues pakSpec # taking all 11 + else map (name: pakSpec.${name}) (splitString " " paksets) 12 + ); 13 14 + ver1 = "120"; 15 + ver2 = "0"; 16 + ver3 = "1"; 17 + version = "${ver1}.${ver2}.${ver3}"; 18 + ver_dash = "${ver1}-${ver2}-${ver3}"; 19 + ver2_dash = "${ver1}-${ver2}"; 20 + 21 + binary_src = fetchurl { 22 + url = "mirror://sourceforge/simutrans/simutrans/${ver_dash}/simutrans-src-${ver_dash}.zip"; 23 + sha256 = "10rn259nxq2hhfpar8zwgxi1p4djvyygcm2f6qhih7l9clvnw2h1"; 24 }; 25 + 26 + 27 + # As of 2015/03, many packsets still didn't have a release for version 120. 28 + pakSpec = stdenv.lib.mapAttrs 29 + (pakName: attrs: mkPak (attrs // {inherit pakName;})) 30 + { 31 + pak64 = { 32 + srcPath = "${ver2_dash}/simupak64-${ver_dash}"; 33 + sha256 = "0y5v1ncpjyhjkkznqmk13kg5d0slhjbbvg1y8q5jxhmhlkghk9q2"; 34 + }; 35 + "pak64.japan" = { 36 + srcPath = "${ver2_dash}/simupak64.japan-${ver_dash}"; 37 + sha256 = "14swy3h4ij74bgaw7scyvmivfb5fmp21nixmhlpk3mav3wr3167i"; 38 + }; 39 + 40 + pak128 = { 41 + srcPath = "pak128%20for%20ST%20120%20%282.5.2%2B%20nightly%20r1560%2C%20bugfixes%29/pak128-r1560--ST120"; 42 + sha256 = "1wd51brc4aglqi3w7s8fxgxrw0k7f653w4wbnmk83k07fwfdyf24"; 43 + }; 44 + "pak128.britain" = { 45 + srcPath = "pak128.Britain%20for%20${ver2_dash}/pak128.Britain.1.16-${ver2_dash}"; 46 + sha256 = "1rww9rnpk22l2z3s1d7y2gmd6iwhv72s7pff8krnh7z0q386waak"; 47 + }; 48 + "pak128.cs" = { # note: it needs pak128 to work 49 + url = "mirror://sourceforge/simutrans/Pak128.CS/pak128.cz_v.0.2.1.zip"; 50 + sha256 = "008d8x1s0vxsq78rkczlnf57pv1n5hi1v5nbd1l5w3yls7lk11sc"; 51 + }; 52 + "pak128.german" = { 53 + url = "mirror://sourceforge/simutrans/PAK128.german/" 54 + + "PAK128.german_0.7_${ver1}.x/PAK128.german_0.7.0.1_${ver1}.x.zip"; 55 + sha256 = "1575akms18raxaijy2kfyqm07wdx6y5q85n7wgvq2fqydrnx33w8"; 56 + }; 57 + 58 + /* This release contains accented filenames that prevent unzipping. 59 + "pak192.comic" = { 60 + srcPath = "pak192comic%20for%20${ver2_dash}/pak192comic-0.4-${ver2_dash}up"; 61 + sha256 = throw ""; 62 + }; 63 + */ 64 }; 65 + 66 + 67 + mkPak = { 68 + sha256, pakName, srcPath ? null 69 + , url ? "mirror://sourceforge/simutrans/${pakName}/${srcPath}.zip" 70 + }: 71 + stdenv.mkDerivation { 72 + name = "simutrans-${pakName}"; 73 + unpackPhase = "true"; 74 + installPhase = let src = fetchurl { inherit url sha256; }; 75 + in '' 76 + mkdir -p "$out/share/simutrans/${pakName}" 77 + cd "$out/share/simutrans/${pakName}" 78 + "${unzip}/bin/unzip" "${src}" 79 + chmod -R +w . # some zipfiles need that 80 + 81 + set +o pipefail # no idea why it's needed 82 + toStrip=`find . -iname '*.pak' | head -n 1 | sed 's|\./\(.*\)/[^/]*$|\1|'` 83 + echo "Detected path '$toStrip' to strip" 84 + mv ./"$toStrip"/* . 85 + rmdir -p "$toStrip" 86 + ''; 87 + }; 88 89 + /* The binaries need all data in one directory; the default is directory 90 + of the executable, and another option is the current directory :-/ */ 91 + withPaks = paks: buildEnv { 92 inherit (binaries) name; 93 + paths = [binaries] ++ paks; 94 + postBuild = '' 95 + rm "$out/bin" && mkdir "$out/bin" 96 + cat > "$out/bin/simutrans" <<EOF 97 + #!${stdenv.shell} 98 + cd "$out"/share/simutrans 99 + exec "${binaries}/bin/simutrans" -use_workdir "\''${extraFlagsArray[@]}" "\$@" 100 + EOF 101 + chmod +x "$out/bin/simutrans" 102 + ''; 103 + 104 + passthru.meta = binaries.meta // { hydraPlatforms = []; }; 105 + passthru.binaries = binaries; 106 }; 107 108 binaries = stdenv.mkDerivation rec { 109 + name = "simutrans-${version}"; 110 111 + src = binary_src; 112 113 sourceRoot = "."; 114 115 + buildInputs = [ pkgconfig zlib libpng bzip2 SDL SDL_mixer unzip ]; 116 117 + configurePhase = let 118 + # Configuration as per the readme.txt and config.template 119 + platform = 120 + if stdenv.isLinux then "linux" else 121 + if stdenv.isDarwin then "mac" else throw "add your platform"; 122 + config = '' 123 + BACKEND = mixer_sdl 124 + COLOUR_DEPTH = 16 125 + OSTYPE = ${platform} 126 + VERBOSE = 1 127 + ''; 128 + #TODO: MULTI_THREAD = 1 is "highly recommended", 129 + # but it's roughly doubling CPU usage for me 130 + in '' 131 + echo "${config}" > config.default 132 133 + # Use ~/.simutrans instead of ~/simutrans 134 + substituteInPlace simsys.cc --replace '%s/simutrans' '%s/.simutrans' 135 136 + # use -O2 optimization (defaults are -O or -O3) 137 + sed -i -e '/CFLAGS += -O/d' Makefile 138 + export CFLAGS+=-O2 139 ''; 140 141 + enableParallelBuilding = true; 142 + 143 installPhase = '' 144 mkdir -p $out/share/ 145 mv simutrans $out/share/ 146 147 mkdir -p $out/bin/ 148 mv build/default/sim $out/bin/simutrans 149 ''; 150 151 + meta = with stdenv.lib; { 152 description = "A simulation game in which the player strives to run a successful transport system"; 153 longDescription = '' 154 Simutrans is a cross-platform simulation game in which the ··· 158 ''; 159 160 homepage = http://www.simutrans.com/; 161 + license = with licenses; [ artistic1 gpl1Plus ]; 162 + maintainers = with maintainers; [ kkallio vcunat ]; 163 + platforms = with platforms; linux ++ darwin; 164 }; 165 }; 166 167 in result 168 +
+2
pkgs/top-level/all-packages.nix
··· 12798 }; 12799 12800 simutrans = callPackage ../games/simutrans { }; 12801 12802 soi = callPackage ../games/soi {}; 12803
··· 12798 }; 12799 12800 simutrans = callPackage ../games/simutrans { }; 12801 + # get binaries without data built by Hydra 12802 + simutrans_binaries = lowPrio simutrans.binaries; 12803 12804 soi = callPackage ../games/soi {}; 12805