1 { stdenv, lib, fetchpatch, fetchpatch2, 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"
61 # Fix build with libxml v2.12
62 # FIXME: Remove with next package update
64 name = "libxml-2.12-fix.patch";
65 url = "https://github.com/0ad/0ad/commit/d242631245edb66816ef9960bdb2c61b68e56cec.patch";
66 hash = "sha256-Ik8ThkewB7wyTPTI7Y6k88SqpWUulXK698tevfSBr6I=";
68 # Fix build with GCC 13
69 # FIXME: Remove with next package update
71 name = "gcc-13-fix.patch";
72 url = "https://github.com/0ad/0ad/commit/093e1eb23519ab4a4633a999a555a58e4fd5343e.patch";
73 hash = "sha256-NuWO64narU1JID/F3cj7lJKjo96XR7gSW0w8I3/hhuw=";
75 # Fix build with miniupnpc 2.2.8
76 # https://github.com/0ad/0ad/pull/45
78 url = "https://github.com/0ad/0ad/commit/1575580bbc5278576693f3fbbb32de0b306aa27e.patch?full_index=1";
79 hash = "sha256-iXiUYTJCWwJpb2U3P58jTV4OpyW6quofu8Jq6xNEq48=";
84 # Delete shipped libraries which we don't need.
85 rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
88 pushd build/workspaces
89 ./update-workspaces.sh \
92 ${lib.optionalString withEditor "--enable-atlas"} \
94 --libdir="$out"/lib/0ad \
99 # Move to the build directory.
100 pushd build/workspaces/gcc
103 enableParallelBuilding = true;
109 install -Dm755 binaries/system/pyrogenesis "$out"/bin/0ad
110 ${lib.optionalString withEditor ''
111 install -Dm755 binaries/system/ActorEditor "$out"/bin/ActorEditor
115 install -Dm755 -t $out/share/0ad/data/l10n binaries/data/l10n/*
118 install -Dm644 -t $out/lib/0ad binaries/system/*.so
121 install -D build/resources/0ad.png $out/share/icons/hicolor/128x128/apps/0ad.png
122 install -D build/resources/0ad.desktop $out/share/applications/0ad.desktop
126 description = "Free, open-source game of ancient warfare";
127 homepage = "https://play0ad.com/";
128 license = with licenses; [
129 gpl2Plus lgpl21 mit cc-by-sa-30
130 licenses.zlib # otherwise masked by pkgs.zlib
132 maintainers = with maintainers; [ chvp ];
133 platforms = subtractLists platforms.i686 platforms.linux;