summary refs log tree commit diff
path: root/pkgs/games/simutrans
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2013-02-02 12:36:38 +0100
committerVladimír Čunát <vcunat@gmail.com>2013-02-02 12:38:15 +0100
commit602e6a94eea1e942deb24a9a943c780115bacd48 (patch)
treeccfa5ac1cafd96952fa0dd3f0a68c7cd0c94e3bc /pkgs/games/simutrans
parent864c2ed99c5bf1ac91574296e59d3023b3f5aab3 (diff)
downloadnixlib-602e6a94eea1e942deb24a9a943c780115bacd48.tar
nixlib-602e6a94eea1e942deb24a9a943c780115bacd48.tar.gz
nixlib-602e6a94eea1e942deb24a9a943c780115bacd48.tar.bz2
nixlib-602e6a94eea1e942deb24a9a943c780115bacd48.tar.lz
nixlib-602e6a94eea1e942deb24a9a943c780115bacd48.tar.xz
nixlib-602e6a94eea1e942deb24a9a943c780115bacd48.tar.zst
nixlib-602e6a94eea1e942deb24a9a943c780115bacd48.zip
simutrans: fix, update, split data, make pak128 the default
Today the monitor resolutions are quite high, so I set pak128 as the default.
It's easy to change.
Diffstat (limited to 'pkgs/games/simutrans')
-rw-r--r--pkgs/games/simutrans/default.nix137
1 files changed, 77 insertions, 60 deletions
diff --git a/pkgs/games/simutrans/default.nix b/pkgs/games/simutrans/default.nix
index c0f9d213762b..3682f9e4f4f8 100644
--- a/pkgs/games/simutrans/default.nix
+++ b/pkgs/games/simutrans/default.nix
@@ -1,78 +1,95 @@
-{ stdenv, fetchurl, unzip, zlib, libpng, bzip2, SDL, SDL_mixer } :
+{ stdenv, fetchurl, unzip, zlib, libpng, bzip2, SDL, SDL_mixer, makeWrapper } :
 
 let
-  # This is the default "pakset" of objects, images, text, music, etc.
-  pak64 = fetchurl {
-    url = http://sourceforge.net/projects/simutrans/files/pak64/110-0-1/simupak64-110-0-1.zip/download;
-    name = "pak64.zip";
-    sha256 = "0gs6k9dbbhh60g2smsx2jza65vyss616bpngwpvilrvb5rzzrxcq";
-  };
+  result = withPak (mkPak pak128);
+
+  ver_1 = "112";
+  ver_2 = "1";
+  ver_h2 = "${ver_1}-${ver_2}";
 
-  # The source distribution seems to be missing some text files.
-  # So we will get them from the binary Linux release (which apparently has them).
-  langtab = fetchurl {
-    url = http://sourceforge.net/projects/simutrans/files/simutrans/110-0-1/simulinux-110-0-1.zip/download;
-    name = "simulinux-110-0-1.zip";
-    sha256 = "15z13kazdzhfzwxry7a766xkkdzaidvscylzrjkx3nnbcq6461s4";
+  # "pakset" of objects, images, text, music, etc.
+  mkPak = src: stdenv.mkDerivation {
+    name = "simutrans-pakset";
+    inherit src;
+    unpackPhase = "true";
+    buildInputs = [ unzip ];
+    installPhase = ''
+      mkdir -p $out
+      cd $out
+      unzip ${src}
+      mv simutrans/*/* .
+      rm -rf simutrans
+    '';
+  };
+  pak64 = fetchurl {
+    url = "mirror://sourceforge/simutrans/pak64/${ver_h2}/simupak64-${ver_h2}.zip";
+    sha256 = "1197rl2534wx9wdafarlr42qjw6pyghz4bynq2g68pi10h8csypw";
   };
-in
-stdenv.mkDerivation rec {
-  pname = "simutrans";
-  version = "110.0.1";
-  name = "${pname}-${version}";
-
-  src = fetchurl {
-    url = "http://github.com/aburch/simutrans/tarball/v110.0.1";
-    name = "${name}.tar.gz";
-    sha256 = "ab0e42e5013d6d2fd5d3176b39dc45e482583b3bad178aac1188bf2ec88feb51";
+  pak128 = fetchurl {
+    url = "mirror://sourceforge/simutrans/pak128/pak128%20for%20${ver_1}/pak128-2.2.0--${ver_1}.0.zip";
+    sha256 = "13rwv9q3fa3ac0k11ds7zkpd00k4mn14rb0cknknvyz46icb9n80";
   };
 
-  buildInputs = [ zlib libpng bzip2 SDL SDL_mixer unzip ];
+  withPak = pak: stdenv.mkDerivation {
+    inherit (binaries) name;
+    unpackPhase = "true";
+    buildInputs = [ makeWrapper ];
+    installPhase = ''makeWrapper "${binaries}/bin/simutrans" "$out/bin/simutrans" --add-flags -objects --add-flags "${pak}"'';
+  };
 
-  prePatch = ''
-    # Use ~/.simutrans instead of ~/simutrans
-    sed -i 's@%s/simutrans@%s/.simutrans@' simsys_s.cc
-  '';
+  binaries = stdenv.mkDerivation rec {
+    pname = "simutrans";
+    name = "${pname}-${ver_1}.${ver_2}";
 
-  preConfigure = ''
-    # Configuration as per the readme.txt
-    sed -i 's@#BACKEND = sdl@BACKEND = sdl@' config.template
-    sed -i 's@#COLOUR_DEPTH = 16@COLOUR_DEPTH = 16@' config.template
-    sed -i 's@#OSTYPE = linux@OSTYPE = linux@' config.template
-    sed -i 's@#OPTIMISE = 1@OPTIMISE = 1@' config.template
+    src = fetchurl {
+      url = "mirror://sourceforge/simutrans/simutrans/${ver_h2}/simutrans-src-${ver_h2}.zip";
+      sha256 = "1xrxpd5m2dc9bk8w21smfj28r41ji1qaihjwkwrifgz6rhg19l5c";
+    };
+    sourceRoot = ".";
 
-    cp config.template config.default
-  '';
+    buildInputs = [ zlib libpng bzip2 SDL SDL_mixer unzip ];
 
-  installPhase = ''
-    # Erase the source distribution object definitions, will be replaced with langtab.
-    rm -r simutrans
+    preConfigure = ''
+      # Configuration as per the readme.txt
+      sed \
+        -e 's@#BACKEND = sdl@BACKEND = sdl@' \
+        -e 's@#COLOUR_DEPTH = 16@COLOUR_DEPTH = 16@' \
+        -e 's@#OSTYPE = linux@OSTYPE = linux@' \
+        < config.template > config.default
 
-    # Default pakset and binary release core objects.
-    unzip ${pak64}
-    unzip ${langtab}
+      # Different default data dir
+      sed -i -e 's:argv\[0\]:"'$out'/share/simutrans/":' \
+        simmain.cc
 
-    mv sim simutrans/
+      # Use ~/.simutrans instead of ~/simutrans ##not working
+      #sed -i -e 's@%s/simutrans@%s/.simutrans@' simsys_s.cc
 
-    mkdir -p $out/simutrans
-    cp -r simutrans $out
+      # No optimization overriding
+      sed -i -e '/-O$/d' Makefile
+    '';
 
-    mkdir -p $out/bin
-    ln -s $out/simutrans/sim $out/bin/simutrans
-  '';
+    installPhase = ''
+      mkdir -p $out/share/
+      mv simutrans $out/share/
 
-  meta = {
-    description = "Simutrans is 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.
+      mkdir -p $out/bin/
+      mv build/default/sim $out/bin/simutrans
     '';
 
-    homepage = http://www.simutrans.com/;
-    license = "Artistic";
-    maintainers = [ stdenv.lib.maintainers.kkallio ];
-    platforms = stdenv.lib.platforms.linux;
+    meta = {
+      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/;
+      license = "Artistic";
+      maintainers = [ stdenv.lib.maintainers.kkallio ];
+      platforms = stdenv.lib.platforms.linux;
+    };
   };
-}
+
+in result