2015-03-19 23:09:20 +03:00
|
|
|
{ stdenv, fetchurl, pkgconfig, unzip, zlib, libpng, bzip2, SDL, SDL_mixer
|
2019-02-26 14:45:54 +03:00
|
|
|
, buildEnv, config, runtimeShell
|
2015-03-19 23:09:20 +03:00
|
|
|
}:
|
2011-03-26 10:22:24 +03:00
|
|
|
|
|
|
|
let
|
2015-03-19 23:09:20 +03:00
|
|
|
# Choose your "paksets" of objects, images, text, music, etc.
|
2017-12-11 01:01:04 +03:00
|
|
|
paksets = config.simutrans.paksets or "pak64 pak64.japan pak128 pak128.britain pak128.german";
|
2015-03-19 23:09:20 +03:00
|
|
|
|
|
|
|
result = with stdenv.lib; withPaks (
|
|
|
|
if paksets == "*" then attrValues pakSpec # taking all
|
|
|
|
else map (name: pakSpec.${name}) (splitString " " paksets)
|
|
|
|
);
|
|
|
|
|
|
|
|
ver1 = "120";
|
2017-12-11 01:01:04 +03:00
|
|
|
ver2 = "2";
|
|
|
|
ver3 = "2";
|
2015-03-19 23:09:20 +03:00
|
|
|
version = "${ver1}.${ver2}.${ver3}";
|
|
|
|
ver_dash = "${ver1}-${ver2}-${ver3}";
|
|
|
|
|
|
|
|
binary_src = fetchurl {
|
|
|
|
url = "mirror://sourceforge/simutrans/simutrans/${ver_dash}/simutrans-src-${ver_dash}.zip";
|
2017-12-11 01:01:04 +03:00
|
|
|
sha256 = "1yi6rwbrnfd65qfz63cncw2n56pbypvg6cllwh71mgvs6x2c28kz";
|
2013-02-02 15:36:38 +04:00
|
|
|
};
|
2015-03-19 23:09:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
# As of 2015/03, many packsets still didn't have a release for version 120.
|
|
|
|
pakSpec = stdenv.lib.mapAttrs
|
|
|
|
(pakName: attrs: mkPak (attrs // {inherit pakName;}))
|
|
|
|
{
|
|
|
|
pak64 = {
|
2017-12-11 01:01:04 +03:00
|
|
|
srcPath = "120-2/simupak64-120-2";
|
|
|
|
sha256 = "1s310pssar4s1nf6gi9cizbx4m75avqm2qk039ha5rk8jk4lzkmk";
|
2015-03-19 23:09:20 +03:00
|
|
|
};
|
|
|
|
"pak64.japan" = {
|
2017-12-11 01:01:04 +03:00
|
|
|
# No release for 120.2 yet!
|
2015-12-27 21:07:52 +03:00
|
|
|
srcPath = "120-0/simupak64.japan-120-0-1";
|
2015-03-19 23:09:20 +03:00
|
|
|
sha256 = "14swy3h4ij74bgaw7scyvmivfb5fmp21nixmhlpk3mav3wr3167i";
|
|
|
|
};
|
|
|
|
|
|
|
|
pak128 = {
|
2017-12-11 01:01:04 +03:00
|
|
|
srcPath = "pak128%20for%20ST%20120.2.2%20%282.7%2C%20minor%20changes%29/pak128";
|
|
|
|
sha256 = "1x6g6yfv1hvjyh3ciccly1i2k2n2b63dw694gdg4j90a543rmclg";
|
2015-03-19 23:09:20 +03:00
|
|
|
};
|
|
|
|
"pak128.britain" = {
|
2017-12-11 01:01:04 +03:00
|
|
|
srcPath = "pak128.Britain%20for%20120-1/pak128.Britain.1.17-120-1";
|
2015-12-27 21:07:52 +03:00
|
|
|
sha256 = "1nviwqizvch9n3n826nmmi7c707dxv0727m7lhc1n2zsrrxcxlr5";
|
2015-03-19 23:09:20 +03:00
|
|
|
};
|
|
|
|
"pak128.cs" = { # note: it needs pak128 to work
|
|
|
|
url = "mirror://sourceforge/simutrans/Pak128.CS/pak128.cz_v.0.2.1.zip";
|
|
|
|
sha256 = "008d8x1s0vxsq78rkczlnf57pv1n5hi1v5nbd1l5w3yls7lk11sc";
|
|
|
|
};
|
|
|
|
"pak128.german" = {
|
|
|
|
url = "mirror://sourceforge/simutrans/PAK128.german/"
|
2017-12-11 01:01:04 +03:00
|
|
|
+ "PAK128.german_0.10.x_for_ST_120.x/PAK128.german_0.10.3_for_ST_120.x.zip";
|
|
|
|
sha256 = "1379zcviyf3v0wsli33sqa509k6zlw6fkk57vahc44mrnhka5fpb";
|
2015-03-19 23:09:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This release contains accented filenames that prevent unzipping.
|
|
|
|
"pak192.comic" = {
|
|
|
|
srcPath = "pak192comic%20for%20${ver2_dash}/pak192comic-0.4-${ver2_dash}up";
|
|
|
|
sha256 = throw "";
|
|
|
|
};
|
|
|
|
*/
|
2011-03-26 10:22:24 +03:00
|
|
|
};
|
|
|
|
|
2015-03-19 23:09:20 +03:00
|
|
|
|
|
|
|
mkPak = {
|
|
|
|
sha256, pakName, srcPath ? null
|
|
|
|
, url ? "mirror://sourceforge/simutrans/${pakName}/${srcPath}.zip"
|
|
|
|
}:
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "simutrans-${pakName}";
|
|
|
|
unpackPhase = "true";
|
2016-01-03 12:27:50 +03:00
|
|
|
preferLocalBuild = true;
|
2015-03-19 23:09:20 +03:00
|
|
|
installPhase = let src = fetchurl { inherit url sha256; };
|
|
|
|
in ''
|
|
|
|
mkdir -p "$out/share/simutrans/${pakName}"
|
|
|
|
cd "$out/share/simutrans/${pakName}"
|
|
|
|
"${unzip}/bin/unzip" "${src}"
|
|
|
|
chmod -R +w . # some zipfiles need that
|
|
|
|
|
|
|
|
set +o pipefail # no idea why it's needed
|
|
|
|
toStrip=`find . -iname '*.pak' | head -n 1 | sed 's|\./\(.*\)/[^/]*$|\1|'`
|
|
|
|
echo "Detected path '$toStrip' to strip"
|
|
|
|
mv ./"$toStrip"/* .
|
|
|
|
rmdir -p "$toStrip"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The binaries need all data in one directory; the default is directory
|
|
|
|
of the executable, and another option is the current directory :-/ */
|
|
|
|
withPaks = paks: buildEnv {
|
2013-02-02 15:36:38 +04:00
|
|
|
inherit (binaries) name;
|
2015-03-19 23:09:20 +03:00
|
|
|
paths = [binaries] ++ paks;
|
|
|
|
postBuild = ''
|
|
|
|
rm "$out/bin" && mkdir "$out/bin"
|
|
|
|
cat > "$out/bin/simutrans" <<EOF
|
2019-02-26 14:45:54 +03:00
|
|
|
#!${runtimeShell}
|
2015-03-19 23:09:20 +03:00
|
|
|
cd "$out"/share/simutrans
|
|
|
|
exec "${binaries}/bin/simutrans" -use_workdir "\''${extraFlagsArray[@]}" "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x "$out/bin/simutrans"
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.meta = binaries.meta // { hydraPlatforms = []; };
|
|
|
|
passthru.binaries = binaries;
|
2013-02-02 15:36:38 +04:00
|
|
|
};
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2013-02-02 15:36:38 +04:00
|
|
|
binaries = stdenv.mkDerivation rec {
|
2015-03-19 23:09:20 +03:00
|
|
|
name = "simutrans-${version}";
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2015-03-19 23:09:20 +03:00
|
|
|
src = binary_src;
|
2014-01-31 17:27:55 +04:00
|
|
|
|
2013-02-02 15:36:38 +04:00
|
|
|
sourceRoot = ".";
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2017-09-06 00:26:13 +03:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [ zlib libpng bzip2 SDL SDL_mixer unzip ];
|
2015-03-19 23:09:20 +03:00
|
|
|
|
|
|
|
configurePhase = let
|
|
|
|
# Configuration as per the readme.txt and config.template
|
|
|
|
platform =
|
|
|
|
if stdenv.isLinux then "linux" else
|
|
|
|
if stdenv.isDarwin then "mac" else throw "add your platform";
|
|
|
|
config = ''
|
|
|
|
BACKEND = mixer_sdl
|
|
|
|
COLOUR_DEPTH = 16
|
|
|
|
OSTYPE = ${platform}
|
|
|
|
VERBOSE = 1
|
|
|
|
'';
|
|
|
|
#TODO: MULTI_THREAD = 1 is "highly recommended",
|
|
|
|
# but it's roughly doubling CPU usage for me
|
|
|
|
in ''
|
|
|
|
echo "${config}" > config.default
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2015-03-19 23:09:20 +03:00
|
|
|
# Use ~/.simutrans instead of ~/simutrans
|
|
|
|
substituteInPlace simsys.cc --replace '%s/simutrans' '%s/.simutrans'
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2015-03-19 23:09:20 +03:00
|
|
|
# use -O2 optimization (defaults are -O or -O3)
|
|
|
|
sed -i -e '/CFLAGS += -O/d' Makefile
|
|
|
|
export CFLAGS+=-O2
|
2013-02-02 15:36:38 +04:00
|
|
|
'';
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2015-03-19 23:09:20 +03:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2013-02-02 15:36:38 +04:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/
|
|
|
|
mv simutrans $out/share/
|
2011-03-26 10:22:24 +03:00
|
|
|
|
2013-02-02 15:36:38 +04:00
|
|
|
mkdir -p $out/bin/
|
|
|
|
mv build/default/sim $out/bin/simutrans
|
2011-03-26 10:22:24 +03:00
|
|
|
'';
|
|
|
|
|
2015-03-19 23:09:20 +03:00
|
|
|
meta = with stdenv.lib; {
|
2013-02-02 15:36:38 +04:00
|
|
|
description = "A simulation game in which the player strives to run a successful transport system";
|
|
|
|
longDescription = ''
|
|
|
|
Simutrans is a cross-platform simulation game in which the
|
|
|
|
player strives to run a successful transport system by
|
|
|
|
transporting goods, passengers, and mail between
|
|
|
|
places. Simutrans is an open source remake of Transport Tycoon.
|
|
|
|
'';
|
|
|
|
|
|
|
|
homepage = http://www.simutrans.com/;
|
2015-03-19 23:09:20 +03:00
|
|
|
license = with licenses; [ artistic1 gpl1Plus ];
|
2015-12-27 21:07:52 +03:00
|
|
|
maintainers = with maintainers; [ kkallio vcunat phile314 ];
|
2018-01-01 08:47:37 +03:00
|
|
|
platforms = with platforms; linux; # TODO: ++ darwin;
|
2013-02-02 15:36:38 +04:00
|
|
|
};
|
2011-03-26 10:22:24 +03:00
|
|
|
};
|
2013-02-02 15:36:38 +04:00
|
|
|
|
|
|
|
in result
|