2021-02-13 14:23:35 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, fetchsvn
|
|
|
|
, cmake
|
|
|
|
, pkg-config
|
|
|
|
, makeWrapper
|
|
|
|
, SDL2
|
|
|
|
, glew
|
|
|
|
, openal
|
2021-05-20 23:08:51 +00:00
|
|
|
, OpenAL
|
2021-02-13 14:23:35 +00:00
|
|
|
, libvorbis
|
|
|
|
, libogg
|
|
|
|
, curl
|
|
|
|
, freetype
|
|
|
|
, libjpeg
|
|
|
|
, libpng
|
|
|
|
, harfbuzz
|
|
|
|
, mcpp
|
|
|
|
, wiiuse
|
|
|
|
, angelscript
|
2021-05-20 23:08:51 +00:00
|
|
|
, Cocoa
|
|
|
|
, IOKit
|
2020-07-18 16:06:22 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
|
|
|
dir = "stk-code";
|
2020-05-15 21:57:56 +00:00
|
|
|
assets = fetchsvn {
|
2021-02-13 14:23:35 +00:00
|
|
|
url = "https://svn.code.sf.net/p/supertuxkart/code/stk-assets";
|
|
|
|
rev = "18218";
|
2020-12-25 13:55:36 +00:00
|
|
|
sha256 = "11iv3cqzvbjg33zz5i5gkl2syn6mlw9wqv0jc7h36vjnjqjv17xw";
|
2021-02-13 14:23:35 +00:00
|
|
|
name = "stk-assets";
|
2020-05-15 21:57:56 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
# List of bundled libraries in stk-code/lib to keep
|
|
|
|
# Those are the libraries that cannot be replaced
|
|
|
|
# with system packages.
|
|
|
|
bundledLibraries = [
|
|
|
|
# Bullet 2.87 is incompatible (bullet 2.79 needed whereas 2.87 is packaged)
|
|
|
|
# The api changed in a lot of classes, too much work to adapt
|
|
|
|
"bullet"
|
|
|
|
# Upstream Libenet doesn't yet support IPv6,
|
|
|
|
# So we will use the bundled libenet which
|
|
|
|
# has been fixed to support it.
|
|
|
|
"enet"
|
|
|
|
# Internal library of STK, nothing to do about it
|
|
|
|
"graphics_utils"
|
|
|
|
# This irrlicht is bundled with cmake
|
|
|
|
# whereas upstream irrlicht still uses
|
|
|
|
# archaic Makefiles, too complicated to switch to.
|
|
|
|
"irrlicht"
|
|
|
|
# Not packaged to this date
|
|
|
|
"libraqm"
|
|
|
|
# Not packaged to this date
|
|
|
|
"libsquish"
|
2020-12-25 13:55:36 +00:00
|
|
|
# Not packaged to this date
|
|
|
|
"sheenbidi"
|
2021-05-20 23:08:51 +00:00
|
|
|
]
|
|
|
|
# Our system angelscript causes linking error on ARM
|
|
|
|
# ld: libangelscript.so: undefined reference to
|
|
|
|
# `CallSystemFunctionNative(asCContext*, asCScriptFunction*, void*, unsigned int*, void*, unsigned long&, void*)'
|
|
|
|
# Bundled angelscript compiles fine
|
|
|
|
++ lib.optional stdenv.hostPlatform.isAarch64 "angelscript";
|
2021-02-13 14:23:35 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "supertuxkart";
|
2020-12-25 13:55:36 +00:00
|
|
|
version = "1.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-02-13 14:23:35 +00:00
|
|
|
owner = "supertuxkart";
|
|
|
|
repo = "stk-code";
|
|
|
|
rev = version;
|
2020-12-25 13:55:36 +00:00
|
|
|
sha256 = "1f98whk0v45jgwcsbdsb1qfambvrnbbgwq0w28kjz4278hinwzq6";
|
2021-02-13 14:23:35 +00:00
|
|
|
name = dir;
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
|
2021-02-13 14:23:35 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# Fix build with SDL 2.0.14
|
|
|
|
url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/games-action/supertuxkart/files/supertuxkart-1.2-new-sdl.patch?id=288360dc7ce2f968a2f12099edeace3f3ed1a705";
|
|
|
|
sha256 = "1jgab9393qan8qbqf5bf8cgw4mynlr5a6pggqhybzsmaczgnns3n";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
postPatch = ''
|
2021-05-20 23:08:51 +00:00
|
|
|
# Deletes all bundled libs in stk-code/lib except those
|
|
|
|
# That couldn't be replaced with system packages
|
2020-07-18 16:06:22 +00:00
|
|
|
find lib -maxdepth 1 -type d | egrep -v "^lib$|${(lib.concatStringsSep "|" bundledLibraries)}" | xargs -n1 -L1 -r -I{} rm -rf {}
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
# Allow building with system-installed wiiuse on Darwin
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace 'NOT (APPLE OR HAIKU)) AND USE_SYSTEM_WIIUSE' 'NOT (HAIKU)) AND USE_SYSTEM_WIIUSE'
|
2020-07-18 16:06:22 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2021-02-13 14:23:35 +00:00
|
|
|
SDL2
|
|
|
|
glew
|
|
|
|
libvorbis
|
|
|
|
libogg
|
|
|
|
freetype
|
|
|
|
curl
|
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
harfbuzz
|
|
|
|
mcpp
|
|
|
|
wiiuse
|
2021-05-20 23:08:51 +00:00
|
|
|
]
|
|
|
|
++ lib.optional (!stdenv.hostPlatform.isAarch64) angelscript
|
|
|
|
++ lib.optional stdenv.hostPlatform.isLinux openal
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ OpenAL IOKit Cocoa ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2021-02-13 14:23:35 +00:00
|
|
|
"-DBUILD_RECORDER=OFF" # libopenglrecorder is not in nixpkgs
|
2021-05-20 23:08:51 +00:00
|
|
|
# doesn't work with our 2.35.0 on aarch64-linux
|
|
|
|
"-DUSE_SYSTEM_ANGELSCRIPT=${if !stdenv.hostPlatform.isAarch64 then "ON" else "OFF"}"
|
2020-05-15 21:57:56 +00:00
|
|
|
"-DCHECK_ASSETS=OFF"
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DUSE_SYSTEM_WIIUSE=ON"
|
2020-12-25 13:55:36 +00:00
|
|
|
"-DOpenGL_GL_PREFERENCE=GLVND"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
# Extract binary from built app bundle
|
|
|
|
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
|
|
mkdir $out/bin
|
|
|
|
mv $out/{supertuxkart.app/Contents/MacOS,bin}/supertuxkart
|
|
|
|
rm -rf $out/supertuxkart.app
|
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
# Obtain the assets directly from the fetched store path, to avoid duplicating assets across multiple engine builds
|
|
|
|
preFixup = ''
|
2021-05-20 23:08:51 +00:00
|
|
|
wrapProgram $out/bin/supertuxkart \
|
|
|
|
--set-default SUPERTUXKART_ASSETS_DIR "${assets}" \
|
|
|
|
--set-default SUPERTUXKART_DATADIR "$out/share/supertuxkart" \
|
2020-05-15 21:57:56 +00:00
|
|
|
'';
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A Free 3D kart racing game";
|
|
|
|
longDescription = ''
|
|
|
|
SuperTuxKart is a Free 3D kart racing game, with many tracks,
|
|
|
|
characters and items for you to try, similar in spirit to Mario
|
|
|
|
Kart.
|
|
|
|
'';
|
|
|
|
homepage = "https://supertuxkart.net/";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ pyrolagus peterhoeg ];
|
2021-05-20 23:08:51 +00:00
|
|
|
platforms = with platforms; unix;
|
2021-04-05 15:23:46 +00:00
|
|
|
changelog = "https://github.com/supertuxkart/stk-code/blob/${version}/CHANGELOG.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|