2022-08-05 11:37:48 +00:00
|
|
|
{ stdenv, lib, fetchpatch, perl, fetchurl, python3, fmt, libidn
|
2021-02-22 20:06:43 +00:00
|
|
|
, pkg-config, spidermonkey_78, boost, icu, libxml2, libpng, libsodium
|
2016-11-03 13:43:42 +00:00
|
|
|
, libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc
|
2019-11-10 16:44:34 +00:00
|
|
|
, openal, libGLU, libGL, xorgproto, libX11, libXcursor, nspr, SDL2
|
2022-09-24 19:25:42 +00:00
|
|
|
, gloox, nvidia-texture-tools, freetype
|
2021-02-22 20:06:43 +00:00
|
|
|
, withEditor ? true, wxGTK
|
2016-11-03 13:43:42 +00:00
|
|
|
}:
|
|
|
|
|
2021-02-22 20:06:43 +00:00
|
|
|
# You can find more instructions on how to build 0ad here:
|
|
|
|
# https://trac.wildfiregames.com/wiki/BuildInstructions
|
|
|
|
|
|
|
|
let
|
|
|
|
# the game requires a special version 78.6.0 of spidermonkey, otherwise
|
|
|
|
# we get compilation errors. We override the src attribute of spidermonkey_78
|
|
|
|
# in order to reuse that declartion, while giving it a different source input.
|
|
|
|
spidermonkey_78_6 = spidermonkey_78.overrideAttrs(old: rec {
|
|
|
|
version = "78.6.0";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz";
|
|
|
|
sha256 = "0lyg65v380j8i2lrylwz8a5ya80822l8vcnlx3dfqpd3s6zzjsay";
|
|
|
|
};
|
2021-03-20 14:34:10 +00:00
|
|
|
patches = (old.patches or []) ++ [
|
|
|
|
./spidermonkey-cargo-toml.patch
|
|
|
|
];
|
2021-02-22 20:06:43 +00:00
|
|
|
});
|
|
|
|
in
|
2016-11-03 13:43:42 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "0ad";
|
2022-09-24 19:25:42 +00:00
|
|
|
version = "0.0.26";
|
2016-11-03 13:43:42 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-build.tar.xz";
|
2022-09-24 19:25:42 +00:00
|
|
|
sha256 = "Lhxt9+MxLnfF+CeIZkz/w6eNO/YGBsAAOSdeHRPA7ks=";
|
2016-11-03 13:43:42 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 01:51:26 +00:00
|
|
|
nativeBuildInputs = [ python3 perl pkg-config ];
|
2016-11-03 13:43:42 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2021-02-22 20:06:43 +00:00
|
|
|
spidermonkey_78_6 boost icu libxml2 libpng libjpeg
|
|
|
|
zlib curl libogg libvorbis enet miniupnpc openal libidn
|
2019-11-10 16:44:34 +00:00
|
|
|
libGLU libGL xorgproto libX11 libXcursor nspr SDL2 gloox
|
2022-09-24 19:25:42 +00:00
|
|
|
nvidia-texture-tools libsodium fmt freetype
|
2016-11-03 13:43:42 +00:00
|
|
|
] ++ lib.optional withEditor wxGTK;
|
|
|
|
|
2023-02-19 19:23:32 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [
|
2022-10-24 07:28:30 +00:00
|
|
|
"-I${xorgproto}/include"
|
|
|
|
"-I${libX11.dev}/include"
|
|
|
|
"-I${libXcursor.dev}/include"
|
2016-11-03 13:43:42 +00:00
|
|
|
"-I${SDL2}/include/SDL2"
|
2021-02-22 20:06:43 +00:00
|
|
|
"-I${fmt.dev}/include"
|
2022-10-12 18:02:26 +00:00
|
|
|
"-I${nvidia-texture-tools.dev}/include"
|
|
|
|
];
|
|
|
|
|
|
|
|
NIX_CFLAGS_LINK = toString [
|
|
|
|
"-L${nvidia-texture-tools.lib}/lib/static"
|
2018-12-18 11:05:33 +00:00
|
|
|
];
|
2016-11-03 13:43:42 +00:00
|
|
|
|
2024-01-13 00:56:15 +00:00
|
|
|
patches = [
|
|
|
|
./rootdir_env.patch
|
|
|
|
|
|
|
|
# Fix build with libxml v2.12
|
|
|
|
# FIXME: Remove with next package update
|
|
|
|
(fetchpatch {
|
|
|
|
name = "libxml-2.12-fix.patch";
|
|
|
|
url = "https://github.com/0ad/0ad/commit/d242631245edb66816ef9960bdb2c61b68e56cec.patch";
|
|
|
|
hash = "sha256-Ik8ThkewB7wyTPTI7Y6k88SqpWUulXK698tevfSBr6I=";
|
|
|
|
})
|
|
|
|
# Fix build with GCC 13
|
|
|
|
# FIXME: Remove with next package update
|
|
|
|
(fetchpatch {
|
|
|
|
name = "gcc-13-fix.patch";
|
|
|
|
url = "https://github.com/0ad/0ad/commit/093e1eb23519ab4a4633a999a555a58e4fd5343e.patch";
|
|
|
|
hash = "sha256-NuWO64narU1JID/F3cj7lJKjo96XR7gSW0w8I3/hhuw=";
|
|
|
|
})
|
|
|
|
];
|
2021-04-16 16:40:48 +00:00
|
|
|
|
2016-11-03 13:43:42 +00:00
|
|
|
configurePhase = ''
|
|
|
|
# Delete shipped libraries which we don't need.
|
|
|
|
rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
|
|
|
|
|
|
|
|
# Update Makefiles
|
|
|
|
pushd build/workspaces
|
|
|
|
./update-workspaces.sh \
|
|
|
|
--with-system-nvtt \
|
2021-02-22 20:06:43 +00:00
|
|
|
--with-system-mozjs \
|
2016-11-03 13:43:42 +00:00
|
|
|
${lib.optionalString withEditor "--enable-atlas"} \
|
|
|
|
--bindir="$out"/bin \
|
|
|
|
--libdir="$out"/lib/0ad \
|
|
|
|
--without-tests \
|
|
|
|
-j $NIX_BUILD_CORES
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Move to the build directory.
|
|
|
|
pushd build/workspaces/gcc
|
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Copy executables.
|
|
|
|
install -Dm755 binaries/system/pyrogenesis "$out"/bin/0ad
|
|
|
|
${lib.optionalString withEditor ''
|
|
|
|
install -Dm755 binaries/system/ActorEditor "$out"/bin/ActorEditor
|
|
|
|
''}
|
|
|
|
|
|
|
|
# Copy l10n data.
|
2018-05-20 19:32:03 +00:00
|
|
|
install -Dm755 -t $out/share/0ad/data/l10n binaries/data/l10n/*
|
2016-11-03 13:43:42 +00:00
|
|
|
|
|
|
|
# Copy libraries.
|
2018-05-20 19:32:03 +00:00
|
|
|
install -Dm644 -t $out/lib/0ad binaries/system/*.so
|
2016-11-03 13:43:42 +00:00
|
|
|
|
|
|
|
# Copy icon.
|
2022-11-09 22:00:40 +00:00
|
|
|
install -D build/resources/0ad.png $out/share/icons/hicolor/128x128/apps/0ad.png
|
2018-05-20 19:32:03 +00:00
|
|
|
install -D build/resources/0ad.desktop $out/share/applications/0ad.desktop
|
2016-11-03 13:43:42 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2024-06-07 07:46:46 +00:00
|
|
|
description = "Free, open-source game of ancient warfare";
|
2017-10-22 22:19:28 +00:00
|
|
|
homepage = "https://play0ad.com/";
|
2016-11-03 13:43:42 +00:00
|
|
|
license = with licenses; [
|
|
|
|
gpl2 lgpl21 mit cc-by-sa-30
|
|
|
|
licenses.zlib # otherwise masked by pkgs.zlib
|
|
|
|
];
|
2021-04-16 16:42:32 +00:00
|
|
|
maintainers = with maintainers; [ chvp ];
|
2017-03-30 14:22:49 +00:00
|
|
|
platforms = subtractLists platforms.i686 platforms.linux;
|
2024-05-17 17:11:00 +00:00
|
|
|
mainProgram = "0ad";
|
2016-11-03 13:43:42 +00:00
|
|
|
};
|
|
|
|
}
|