{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  boost,
  SDL2,
  SDL2_image,
  SDL2_ttf,
  libpng,
  glew,
  gettext,
  libsndfile,
  libvorbis,
  libogg,
  physfs,
  openal,
  xmlstarlet,
  doxygen,
  python3,
  callPackage,
  fetchpatch,
}:

let
  colobot-data = callPackage ./data.nix { };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "colobot";
  # Maybe require an update to package colobot-data as well
  # in file data.nix next to this one
  version = "0.2.2-alpha";

  src = fetchFromGitHub {
    owner = "colobot";
    repo = "colobot";
    tag = "colobot-gold-${finalAttrs.version}";
    hash = "sha256-QhNHtAG+hKq7qJhKWCJcP4ejm5YDOU8pyYtitJppVlU=";
  };

  patches = [
    (fetchpatch {
      url = "https://github.com/colobot/colobot/commit/1561854b03500d39955c66971c9c98de1937d7e6.patch";
      relative = "colobot-app/src";
      extraPrefix = "src/app/";
      hash = "sha256-TVd/TsmFb1qQILUJr6E1zdFl/bQkREYKC/cm2I3M/iw=";
    })
  ];

  postPatch = ''
    substituteInPlace CMakeLists.txt \
      --replace-fail 'find_package(Boost COMPONENTS system filesystem regex REQUIRED)' \
                     'find_package(Boost COMPONENTS filesystem regex REQUIRED)'
  '';

  nativeBuildInputs = [
    cmake
    xmlstarlet
    doxygen
    python3
  ];
  buildInputs = [
    boost
    SDL2
    SDL2_image
    SDL2_ttf
    libpng
    glew
    gettext
    libsndfile
    libvorbis
    libogg
    physfs
    openal
  ];

  # The binary ends in games directory
  postInstall = ''
    mv $out/games $out/bin
    for contents in ${colobot-data}/share/games/colobot/*; do
      ln -s $contents $out/share/games/colobot
    done
  '';

  meta = {
    homepage = "https://colobot.info/";
    description = "Real-time strategy game with programmable bots";
    license = lib.licenses.gpl3;
    maintainers = [ ];
    platforms = lib.platforms.linux;
  };
})
