1 { stdenv, lib, fetchpatch, perl, fetchurl, python3, fmt, libidn
2 , pkg-config, spidermonkey_78, boost, icu, libxml2, libpng, libsodium
3 , libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc
4 , openal, libGLU, libGL, xorgproto, libX11, libXcursor, nspr, SDL2
5 , gloox, nvidia-texture-tools, freetype
6 , withEditor ? true, wxGTK
9 # You can find more instructions on how to build 0ad here:
10 # https://trac.wildfiregames.com/wiki/BuildInstructions
13 # the game requires a special version 78.6.0 of spidermonkey, otherwise
14 # we get compilation errors. We override the src attribute of spidermonkey_78
15 # in order to reuse that declartion, while giving it a different source input.
16 spidermonkey_78_6 = spidermonkey_78.overrideAttrs(old: rec {
19 url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz";
20 sha256 = "0lyg65v380j8i2lrylwz8a5ya80822l8vcnlx3dfqpd3s6zzjsay";
22 patches = (old.patches or []) ++ [
23 ./spidermonkey-cargo-toml.patch
27 stdenv.mkDerivation rec {
32 url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-build.tar.xz";
33 sha256 = "Lhxt9+MxLnfF+CeIZkz/w6eNO/YGBsAAOSdeHRPA7ks=";
36 nativeBuildInputs = [ python3 perl pkg-config ];
39 spidermonkey_78_6 boost icu libxml2 libpng libjpeg
40 zlib curl libogg libvorbis enet miniupnpc openal libidn
41 libGLU libGL xorgproto libX11 libXcursor nspr SDL2 gloox
42 nvidia-texture-tools libsodium fmt freetype
43 ] ++ lib.optional withEditor wxGTK;
45 env.NIX_CFLAGS_COMPILE = toString [
46 "-I${xorgproto}/include"
47 "-I${libX11.dev}/include"
48 "-I${libXcursor.dev}/include"
49 "-I${SDL2}/include/SDL2"
50 "-I${fmt.dev}/include"
51 "-I${nvidia-texture-tools.dev}/include"
54 NIX_CFLAGS_LINK = toString [
55 "-L${nvidia-texture-tools.lib}/lib/static"
58 patches = [ ./rootdir_env.patch ];
61 # Delete shipped libraries which we don't need.
62 rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
65 pushd build/workspaces
66 ./update-workspaces.sh \
69 ${lib.optionalString withEditor "--enable-atlas"} \
71 --libdir="$out"/lib/0ad \
76 # Move to the build directory.
77 pushd build/workspaces/gcc
80 enableParallelBuilding = true;
86 install -Dm755 binaries/system/pyrogenesis "$out"/bin/0ad
87 ${lib.optionalString withEditor ''
88 install -Dm755 binaries/system/ActorEditor "$out"/bin/ActorEditor
92 install -Dm755 -t $out/share/0ad/data/l10n binaries/data/l10n/*
95 install -Dm644 -t $out/lib/0ad binaries/system/*.so
98 install -D build/resources/0ad.png $out/share/icons/hicolor/128x128/apps/0ad.png
99 install -D build/resources/0ad.desktop $out/share/applications/0ad.desktop
103 description = "A free, open-source game of ancient warfare";
104 homepage = "https://play0ad.com/";
105 license = with licenses; [
106 gpl2 lgpl21 mit cc-by-sa-30
107 licenses.zlib # otherwise masked by pkgs.zlib
109 maintainers = with maintainers; [ chvp ];
110 platforms = subtractLists platforms.i686 platforms.linux;