2021-01-17 05:49:22 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, unzip, zlib, libpng, bzip2, SDL, SDL_mixer
|
2019-02-26 11:45:54 +00:00
|
|
|
, buildEnv, config, runtimeShell
|
2015-03-19 20:09:20 +00:00
|
|
|
}:
|
2011-03-26 07:22:24 +00:00
|
|
|
|
|
|
|
let
|
2015-03-19 20:09:20 +00:00
|
|
|
# Choose your "paksets" of objects, images, text, music, etc.
|
2017-12-10 22:01:04 +00:00
|
|
|
paksets = config.simutrans.paksets or "pak64 pak64.japan pak128 pak128.britain pak128.german";
|
2015-03-19 20:09:20 +00:00
|
|
|
|
2021-01-15 04:31:39 +00:00
|
|
|
result = with lib; withPaks (
|
2015-03-19 20:09:20 +00:00
|
|
|
if paksets == "*" then attrValues pakSpec # taking all
|
|
|
|
else map (name: pakSpec.${name}) (splitString " " paksets)
|
|
|
|
);
|
|
|
|
|
2021-07-18 23:59:28 +00:00
|
|
|
ver1 = "121";
|
|
|
|
ver2 = "0";
|
|
|
|
ver3 = "";
|
|
|
|
version = "${ver1}.${ver2}${lib.optionalString (ver3 != "") ".${ver3}"}";
|
|
|
|
ver_dash = "${ver1}-${ver2}${lib.optionalString (ver3 != "") "-${ver3}"}";
|
2015-03-19 20:09:20 +00:00
|
|
|
|
|
|
|
binary_src = fetchurl {
|
|
|
|
url = "mirror://sourceforge/simutrans/simutrans/${ver_dash}/simutrans-src-${ver_dash}.zip";
|
2021-07-18 23:59:28 +00:00
|
|
|
sha256 = "1f463r6kr5ig0zd3mncc74k93xbjywsq3d06j5r17831jyc9bzb9";
|
2013-02-02 11:36:38 +00:00
|
|
|
};
|
2015-03-19 20:09:20 +00:00
|
|
|
|
|
|
|
|
2021-07-18 23:59:28 +00:00
|
|
|
# As of 2021/07, many of these paksets have not been updated for years, so are on old versions.
|
2021-01-15 04:31:39 +00:00
|
|
|
pakSpec = lib.mapAttrs
|
2015-03-19 20:09:20 +00:00
|
|
|
(pakName: attrs: mkPak (attrs // {inherit pakName;}))
|
|
|
|
{
|
|
|
|
pak64 = {
|
2021-07-18 23:59:28 +00:00
|
|
|
srcPath = "${ver_dash}/simupak64-${ver_dash}";
|
2020-04-12 08:09:26 +00:00
|
|
|
sha256 = "1k335kh8dhm1hdn5iwn3sdgnrlpk0rqxmmgqgqcwsi09cmw45m5c";
|
2015-03-19 20:09:20 +00:00
|
|
|
};
|
|
|
|
"pak64.japan" = {
|
2021-07-18 23:59:28 +00:00
|
|
|
# No release for 121.0 yet!
|
2015-12-27 18:07:52 +00:00
|
|
|
srcPath = "120-0/simupak64.japan-120-0-1";
|
2015-03-19 20:09:20 +00:00
|
|
|
sha256 = "14swy3h4ij74bgaw7scyvmivfb5fmp21nixmhlpk3mav3wr3167i";
|
|
|
|
};
|
|
|
|
|
|
|
|
pak128 = {
|
2020-04-12 08:09:26 +00:00
|
|
|
srcPath = "pak128%20for%20ST%20120.4.1%20%282.8.1%2C%20priority%20signals%20%2B%20bugfix%29/pak128";
|
2020-03-20 19:06:49 +00:00
|
|
|
sha256 = "0z01y7r0rz7q79vr17bbnkgcbjjrimphy1dwb1pgbiv4klz7j5xw";
|
2015-03-19 20:09:20 +00:00
|
|
|
};
|
|
|
|
"pak128.britain" = {
|
2020-04-12 08:09:26 +00:00
|
|
|
srcPath = "pak128.Britain%20for%20120-1/pak128.Britain.1.18-120-3";
|
|
|
|
sha256 = "1kyb0s54kysvdr0zdln9106yx75d71j4lbw3v87k3i440cj3r1d3";
|
2015-03-19 20:09:20 +00: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/"
|
2020-04-12 08:09:26 +00:00
|
|
|
+ "pak128.german_1.2_for_ST_121.0/PAK128.german_1.2_for_ST_121-0.zip";
|
2020-12-10 09:37:06 +00:00
|
|
|
sha256 = "1cv1rzl1a3i5dvk476zq094wawk9hhdh2f0y4xrdny5gn17mb2xi";
|
2015-03-19 20:09:20 +00: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 07:22:24 +00:00
|
|
|
};
|
|
|
|
|
2015-03-19 20:09:20 +00:00
|
|
|
|
|
|
|
mkPak = {
|
|
|
|
sha256, pakName, srcPath ? null
|
|
|
|
, url ? "mirror://sourceforge/simutrans/${pakName}/${srcPath}.zip"
|
|
|
|
}:
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "simutrans-${pakName}";
|
2019-06-19 15:45:34 +00:00
|
|
|
dontUnpack = true;
|
2016-01-03 09:27:50 +00:00
|
|
|
preferLocalBuild = true;
|
2015-03-19 20:09:20 +00: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"/* .
|
2020-04-12 08:09:26 +00:00
|
|
|
rm -f "$toStrip/.directory" #pak128.german had this
|
2015-03-19 20:09:20 +00:00
|
|
|
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 11:36:38 +00:00
|
|
|
inherit (binaries) name;
|
2015-03-19 20:09:20 +00:00
|
|
|
paths = [binaries] ++ paks;
|
|
|
|
postBuild = ''
|
|
|
|
rm "$out/bin" && mkdir "$out/bin"
|
|
|
|
cat > "$out/bin/simutrans" <<EOF
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
2015-03-19 20:09:20 +00:00
|
|
|
cd "$out"/share/simutrans
|
2019-09-10 22:52:53 +00:00
|
|
|
exec "${binaries}/bin/simutrans" -use_workdir "\$@"
|
2015-03-19 20:09:20 +00:00
|
|
|
EOF
|
|
|
|
chmod +x "$out/bin/simutrans"
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.meta = binaries.meta // { hydraPlatforms = []; };
|
|
|
|
passthru.binaries = binaries;
|
2013-02-02 11:36:38 +00:00
|
|
|
};
|
2011-03-26 07:22:24 +00:00
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
binaries = stdenv.mkDerivation {
|
2019-08-13 21:52:01 +00:00
|
|
|
pname = "simutrans";
|
|
|
|
inherit version;
|
2011-03-26 07:22:24 +00:00
|
|
|
|
2015-03-19 20:09:20 +00:00
|
|
|
src = binary_src;
|
2014-01-31 13:27:55 +00:00
|
|
|
|
2013-02-02 11:36:38 +00:00
|
|
|
sourceRoot = ".";
|
2011-03-26 07:22:24 +00:00
|
|
|
|
2021-02-20 21:01:53 +00:00
|
|
|
nativeBuildInputs = [ pkg-config unzip ];
|
|
|
|
buildInputs = [ zlib libpng bzip2 SDL SDL_mixer ];
|
2015-03-19 20:09:20 +00: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 07:22:24 +00:00
|
|
|
|
2015-03-19 20:09:20 +00:00
|
|
|
# Use ~/.simutrans instead of ~/simutrans
|
|
|
|
substituteInPlace simsys.cc --replace '%s/simutrans' '%s/.simutrans'
|
2011-03-26 07:22:24 +00:00
|
|
|
|
2015-03-19 20:09:20 +00:00
|
|
|
# use -O2 optimization (defaults are -O or -O3)
|
|
|
|
sed -i -e '/CFLAGS += -O/d' Makefile
|
|
|
|
export CFLAGS+=-O2
|
2013-02-02 11:36:38 +00:00
|
|
|
'';
|
2011-03-26 07:22:24 +00:00
|
|
|
|
2015-03-19 20:09:20 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2013-02-02 11:36:38 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/
|
|
|
|
mv simutrans $out/share/
|
2011-03-26 07:22:24 +00:00
|
|
|
|
2013-02-02 11:36:38 +00:00
|
|
|
mkdir -p $out/bin/
|
|
|
|
mv build/default/sim $out/bin/simutrans
|
2011-03-26 07:22:24 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2013-02-02 11:36:38 +00:00
|
|
|
description = "Simulation game in which the player strives to run a successful transport system";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "simutrans";
|
2013-02-02 11:36:38 +00:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://www.simutrans.com/";
|
2015-03-19 20:09:20 +00:00
|
|
|
license = with licenses; [ artistic1 gpl1Plus ];
|
2024-07-28 14:44:11 +00:00
|
|
|
maintainers = [ ];
|
2018-01-01 05:47:37 +00:00
|
|
|
platforms = with platforms; linux; # TODO: ++ darwin;
|
2013-02-02 11:36:38 +00:00
|
|
|
};
|
2011-03-26 07:22:24 +00:00
|
|
|
};
|
2013-02-02 11:36:38 +00:00
|
|
|
|
|
|
|
in result
|