110 lines
3.3 KiB
Nix
110 lines
3.3 KiB
Nix
{ stdenv, lib, fetchFromGitHub, scons, pkgconfig, libX11, libXcursor
|
|
, libXinerama, libXrandr, libXrender, libpulseaudio ? null
|
|
, libXi ? null, libXext, libXfixes, freetype, openssl
|
|
, alsaLib, libGLU, zlib, yasm ? null
|
|
, pkg-config
|
|
, mono, msbuild, dotnet-sdk, dotnetPackages, fetchNuGet
|
|
}:
|
|
|
|
let
|
|
options = {
|
|
touch = libXi != null;
|
|
pulseaudio = false;
|
|
};
|
|
|
|
monoprefix = if builtins.currentSystem == "x86_64-linux"
|
|
then "MONO64_PREFIX=${mono}"
|
|
else "MONO32_PREFIX=${mono}";
|
|
|
|
bits = if builtins.currentSystem == "x86_64-linux"
|
|
then "64"
|
|
else "32";
|
|
|
|
glob = fetchNuGet {
|
|
baseName = "DotNet.Glob";
|
|
version = "2.1.1";
|
|
sha256 = "06pwz1r0sf506l7bhxi8mx6lfhn95v6ns8h3905bgi5950cip84g";
|
|
outputFiles = [ "*" ];
|
|
dllFiles = [ "DotNet.Glob.dll" ];
|
|
};
|
|
|
|
in stdenv.mkDerivation rec {
|
|
pname = "godot";
|
|
version = "3.1.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "godotengine";
|
|
repo = "godot";
|
|
rev = "${version}-stable";
|
|
sha256 = "0lplkwgshh0x7r1daai9gflzwjnp3yfx4724h1myvidaz234v2wh";
|
|
};
|
|
|
|
nativeBuildInputs = [ pkgconfig mono msbuild dotnet-sdk ];
|
|
buildInputs = [
|
|
scons libX11 libXcursor libXinerama libXrandr libXrender
|
|
libXi libXext libXfixes freetype openssl alsaLib libpulseaudio
|
|
libGLU zlib yasm
|
|
pkgconfig
|
|
msbuild dotnetPackages.Nuget glob
|
|
];
|
|
|
|
patches = [
|
|
./pkg_config_additions.patch
|
|
./dont_clobber_environment.patch
|
|
];
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
sconsFlags = "target=release_debug platform=x11 tools=yes module_mono_enabled=yes";
|
|
preConfigure = ''
|
|
sconsFlags+=" ${lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "${k}=${builtins.toJSON v}") options)}"
|
|
'';
|
|
|
|
buildPhase = ''
|
|
#cd ${src}/godot-mono
|
|
echo $NIX_BUILD_CORES
|
|
export ${monoprefix}
|
|
|
|
# Build Mono glue
|
|
|
|
export HOME=$(pwd)
|
|
scons -j "$NIX_BUILD_CORES" platform=x11 tools=yes module_mono_enabled=yes mono_glue=no bits=${bits}
|
|
bin/godot.x11.tools.${bits}.mono --generate-mono-glue modules/mono/glue
|
|
|
|
# Build editor binary
|
|
|
|
scons -j "$NIX_BUILD_CORES" platform=x11 tools=yes target=release_debug module_mono_enabled=yes pulseaudio=no touch=${builtins.toJSON (libXi != null)} bits=${bits}
|
|
scons -j "$NIX_BUILD_CORES" platform=x11 tools=no target=release module_mono_enabled=yes pulseausio=no touch=${builtins.toJSON (libXi != null)} bits=${bits}
|
|
'';
|
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
installPhase = ''
|
|
mkdir -p "$out/bin"
|
|
cp bin/godot.* $out/bin/godot
|
|
cp bin/data.mono.* $out/bin
|
|
|
|
mkdir "$dev"
|
|
cp -r modules/gdnative/include $dev
|
|
|
|
mkdir -p "$man/share/man/man6"
|
|
cp misc/dist/linux/godot.6 "$man/share/man/man6/"
|
|
|
|
mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps}
|
|
cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/"
|
|
cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg"
|
|
cp icon.png "$out/share/icons/godot.png"
|
|
substituteInPlace "$out/share/applications/org.godotengine.Godot.desktop" \
|
|
--replace "Exec=godot" "Exec=$out/bin/godot"
|
|
'';
|
|
|
|
meta = {
|
|
homepage = "https://godotengine.org";
|
|
description = "Free and Open Source 2D and 3D game engine";
|
|
license = stdenv.lib.licenses.mit;
|
|
platforms = [ "i686-linux" "x86_64-linux" ];
|
|
maintainers = with stdenv.lib.maintainers; [ nek0 ];
|
|
priority = 4; # Prioritize Mono-enabled version over default Godot
|
|
};
|
|
}
|