nixpkgs/pkgs/games/0ad/default.nix

132 lines
3.7 KiB
Nix
Raw Normal View History

2014-07-01 15:22:34 +01:00
{ stdenv, callPackage, fetchurl, python27
2015-08-28 22:34:22 +01:00
, pkgconfig, spidermonkey_31, boost, icu, libxml2, libpng
2014-06-18 22:18:53 +01:00
, libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc
2016-01-16 14:08:19 +00:00
, openal, mesa, xproto, libX11, libXcursor, nspr, SDL, SDL2
2014-06-18 22:18:53 +01:00
, gloox, nvidia-texture-tools
, withEditor ? true, wxGTK ? null
}:
assert withEditor -> wxGTK != null;
let
2016-04-30 13:46:45 +01:00
version = "0.0.20";
2014-06-18 22:18:53 +01:00
releaseType = "alpha";
zeroadData = callPackage ./data.nix { inherit version releaseType; };
archForPremake =
2014-07-01 15:22:34 +01:00
if stdenv.lib.hasPrefix "x86_64-" stdenv.system then "x64" else
if stdenv.lib.hasPrefix "i686-" stdenv.system then "x32" else "ERROR";
2014-06-18 22:18:53 +01:00
in
stdenv.mkDerivation rec {
name = "0ad-${version}";
src = fetchurl {
url = "http://releases.wildfiregames.com/0ad-${version}-${releaseType}-unix-build.tar.xz";
2016-04-30 13:46:45 +01:00
sha256 = "13n61xhjsawda3kl7112la41bqkbqmq4yhr3slydsz856z5xb5m3";
2014-06-18 22:18:53 +01:00
};
buildInputs = [
2015-08-28 22:34:22 +01:00
zeroadData python27 pkgconfig spidermonkey_31 boost icu
2014-06-18 22:18:53 +01:00
libxml2 libpng libjpeg zlib curl libogg libvorbis enet
2015-05-16 03:00:54 +01:00
miniupnpc openal mesa xproto libX11 libXcursor nspr
2016-01-16 14:08:19 +00:00
SDL SDL2 gloox nvidia-texture-tools
2014-06-18 22:18:53 +01:00
] ++ stdenv.lib.optional withEditor wxGTK;
NIX_CFLAGS_COMPILE = [
"-I${xproto}/include/X11"
"-I${libX11.dev}/include/X11"
"-I${libXcursor.dev}/include/X11"
2016-01-16 14:08:19 +00:00
"-I${SDL}/include/SDL"
"-I${SDL2}/include/SDL2"
2014-06-18 22:18:53 +01:00
];
2015-08-28 22:34:22 +01:00
patchPhase = ''
sed -i 's/MOZJS_MINOR_VERSION/false \&\& MOZJS_MINOR_VERSION/' source/scriptinterface/ScriptTypes.h
'';
2014-06-18 22:18:53 +01:00
configurePhase = ''
# Delete shipped libraries which we don't need.
rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
# Build shipped premake.
make -C build/premake/premake4/build/gmake.unix
# Run premake.
pushd build/premake
./premake4/bin/release/premake4 \
--file="premake4.lua" \
--outpath="../workspaces/gcc/" \
--platform=${archForPremake} \
--os=linux \
--with-system-nvtt \
--with-system-enet \
--with-system-miniupnpc \
2015-08-28 22:34:22 +01:00
--with-system-mozjs31 \
2014-06-18 22:18:53 +01:00
${ if withEditor then "--atlas" else "" } \
--collada \
--bindir="$out"/bin \
--libdir="$out"/lib/0ad \
--datadir="$out"/share/0ad \
2015-02-03 05:33:48 +00:00
--without-tests \
2014-06-18 22:18:53 +01:00
gmake
popd
'';
buildPhase = ''
# Build bundled fcollada.
make -C libraries/source/fcollada/src
# Build 0ad.
make -C build/workspaces/gcc verbose=1
'';
installPhase = ''
# Copy executables.
mkdir -p "$out"/bin
cp binaries/system/pyrogenesis "$out"/bin/0ad
2014-06-18 22:18:53 +01:00
((${ toString withEditor })) && cp binaries/system/ActorEditor "$out"/bin/
# Copy l10n data.
mkdir -p "$out"/share/0ad
cp -r binaries/data/l10n "$out"/share/0ad/
# Copy libraries.
mkdir -p "$out"/lib/0ad
cp binaries/system/libCollada.so "$out"/lib/0ad/
((${ toString withEditor })) && cp binaries/system/libAtlasUI.so "$out"/lib/0ad/
# Create links to data files.
ln -s -t "$out"/share/0ad "${zeroadData}"/share/0ad/*
# Copy icon.
mkdir -p "$out"/share/icons
cp build/resources/0ad.png "$out"/share/icons/
# Copy/fix desktop item.
mkdir -p "$out"/share/applications
while read LINE; do
if [[ $LINE = "Exec=0ad" ]]; then
2016-01-20 10:27:37 +00:00
echo "Exec=$out/bin/zeroad"
2014-06-18 22:18:53 +01:00
elif [[ $LINE = "Icon=0ad" ]]; then
echo "Icon=$out/share/icons/0ad.png"
else
echo "$LINE"
fi
done <build/resources/0ad.desktop >"$out"/share/applications/0ad.desktop
'';
meta = with stdenv.lib; {
2014-06-18 22:18:53 +01:00
description = "A free, open-source game of ancient warfare";
homepage = "http://wildfiregames.com/0ad/";
license = with licenses; [
gpl2 lgpl21 mit cc-by-sa-30
licenses.zlib # otherwise masked by pkgs.zlib
];
2014-06-18 22:18:53 +01:00
platforms = [ "x86_64-linux" "i686-linux" ];
hydraPlatforms = []; # the data are too big (~1.5 GB)
2014-06-18 22:18:53 +01:00
};
}