<commit_before>{ stdenv, fetchurl, unzip, zlib, libpng, bzip2, SDL, SDL_mixer, makeWrapper } :

let
  result = withPak (mkPak pak128);

  ver_1 = "112";
  ver_2 = "1";
  ver_h2 = "${ver_1}-${ver_2}";

  # "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";
  };
  pak128 = fetchurl {
    url = "mirror://sourceforge/simutrans/pak128/pak128%20for%20${ver_1}/pak128-2.2.0--${ver_1}.0.zip";
    sha256 = "13rwv9q3fa3ac0k11ds7zkpd00k4mn14rb0cknknvyz46icb9n80";
  };

  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}"'';
  };

  binaries = stdenv.mkDerivation rec {
    pname = "simutrans";
    name = "${pname}-${ver_1}.${ver_2}";

    src = fetchurl {
      url = "mirror://sourceforge/simutrans/simutrans/${ver_h2}/simutrans-src-${ver_h2}.zip";
      sha256 = "1xrxpd5m2dc9bk8w21smfj28r41ji1qaihjwkwrifgz6rhg19l5c";
    };
    sourceRoot = ".";

    buildInputs = [ zlib libpng bzip2 SDL SDL_mixer unzip ];

    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

      # Different default data dir
      sed -i -e 's:argv\[0\]:"'$out'/share/simutrans/":' \
        simmain.cc

      # Use ~/.simutrans instead of ~/simutrans ##not working
      #sed -i -e 's@%s/simutrans@%s/.simutrans@' simsys_s.cc

      # No optimization overriding
      sed -i -e '/-O$/d' Makefile<commit_msg>simutrans: pass meta into the final package so it's built by hydra<commit_after>{ stdenv, fetchurl, unzip, zlib, libpng, bzip2, SDL, SDL_mixer, makeWrapper } :

let
  result = withPak (mkPak pak128);

  ver_1 = "112";
  ver_2 = "1";
  ver_h2 = "${ver_1}-${ver_2}";

  # "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";
  };
  pak128 = fetchurl {
    url = "mirror://sourceforge/simutrans/pak128/pak128%20for%20${ver_1}/pak128-2.2.0--${ver_1}.0.zip";
    sha256 = "13rwv9q3fa3ac0k11ds7zkpd00k4mn14rb0cknknvyz46icb9n80";
  };

  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}"'';
    inherit (binaries) meta;
  };

  binaries = stdenv.mkDerivation rec {
    pname = "simutrans";
    name = "${pname}-${ver_1}.${ver_2}";

    src = fetchurl {
      url = "mirror://sourceforge/simutrans/simutrans/${ver_h2}/simutrans-src-${ver_h2}.zip";
      sha256 = "1xrxpd5m2dc9bk8w21smfj28r41ji1qaihjwkwrifgz6rhg19l5c";
    };
    sourceRoot = ".";

    buildInputs = [ zlib libpng bzip2 SDL SDL_mixer unzip ];

    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

      # Different default data dir
      sed -i -e 's:argv\[0\]:"'$out'/share/simutrans/":' \
        simmain.cc

      # Use ~/.simutrans instead of ~/simutrans ##not working
      #sed -i -e 's@%s/simutrans@%s/.simutrans@' simsys_s.cc

      # No optimization overriding
      sed -i -e '/-O$/d' Makefile
{'fraction_non_alphanumeric': 0.1580512351326624, 'fraction_numerical': 0.0535224153705398, 'mean_word_length': 2.8192139737991266, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1664216', 'n_tokens_mistral': 1954, 'n_tokens_neox': 1768, 'n_words': 319}