@@ -1,131 +1,14 @@
1−{ stdenv, callPackage, fetchurl, python27
2−, pkgconfig, spidermonkey_31, boost, icu, libxml2, libpng
3−, libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc
4−, openal, mesa, xproto, libX11, libXcursor, nspr, SDL, SDL2
5−, gloox, nvidia-texture-tools
6−, withEditor ? true, wxGTK ? null
7−}:
8−
9−assert withEditor -> wxGTK != null;
1+{ newScope }:
102
113let
12− version = "0.0.20";
13−
14− releaseType = "alpha";
15−
16− zeroadData = callPackage ./data.nix { inherit version releaseType; };
4+ callPackage = newScope self;
175
18− archForPremake =
19− if stdenv.lib.hasPrefix "x86_64-" stdenv.system then "x64" else
20− if stdenv.lib.hasPrefix "i686-" stdenv.system then "x32" else "ERROR";
6+ self = {
7+ zeroad-unwrapped = callPackage ./game.nix { };
218
22−in
23−stdenv.mkDerivation rec {
24− name = "0ad-${version}";
9+ zeroad-data = callPackage ./data.nix { };
2510
26− src = fetchurl {
27− url = "http://releases.wildfiregames.com/0ad-${version}-${releaseType}-unix-build.tar.xz";
28− sha256 = "13n61xhjsawda3kl7112la41bqkbqmq4yhr3slydsz856z5xb5m3";
11+ zeroad = callPackage ./wrapper.nix { };
2912 };
3013
31− buildInputs = [
32− zeroadData python27 pkgconfig spidermonkey_31 boost icu
33− libxml2 libpng libjpeg zlib curl libogg libvorbis enet
34− miniupnpc openal mesa xproto libX11 libXcursor nspr
35− SDL SDL2 gloox nvidia-texture-tools
36− ] ++ stdenv.lib.optional withEditor wxGTK;
37−
38− NIX_CFLAGS_COMPILE = [
39− "-I${xproto}/include/X11"
40− "-I${libX11.dev}/include/X11"
41− "-I${libXcursor.dev}/include/X11"
42− "-I${SDL.dev}/include/SDL"
43− "-I${SDL2}/include/SDL2"
44− ];
45−
46− patchPhase = ''
47− sed -i 's/MOZJS_MINOR_VERSION/false \&\& MOZJS_MINOR_VERSION/' source/scriptinterface/ScriptTypes.h
48− '';
49−
50− configurePhase = ''
51− # Delete shipped libraries which we don't need.
52− rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
53−
54− # Build shipped premake.
55− make -C build/premake/premake4/build/gmake.unix
56−
57− # Run premake.
58− pushd build/premake
59− ./premake4/bin/release/premake4 \
60− --file="premake4.lua" \
61− --outpath="../workspaces/gcc/" \
62− --platform=${archForPremake} \
63− --os=linux \
64− --with-system-nvtt \
65− --with-system-enet \
66− --with-system-miniupnpc \
67− --with-system-mozjs31 \
68− ${ if withEditor then "--atlas" else "" } \
69− --collada \
70− --bindir="$out"/bin \
71− --libdir="$out"/lib/0ad \
72− --datadir="$out"/share/0ad \
73− --without-tests \
74− gmake
75− popd
76− '';
77−
78− buildPhase = ''
79− # Build bundled fcollada.
80− make -C libraries/source/fcollada/src
81−
82− # Build 0ad.
83− make -C build/workspaces/gcc verbose=1
84− '';
85−
86− installPhase = ''
87− # Copy executables.
88− mkdir -p "$out"/bin
89− cp binaries/system/pyrogenesis "$out"/bin/0ad
90− ((${ toString withEditor })) && cp binaries/system/ActorEditor "$out"/bin/
91−
92− # Copy l10n data.
93− mkdir -p "$out"/share/0ad
94− cp -r binaries/data/l10n "$out"/share/0ad/
95−
96− # Copy libraries.
97− mkdir -p "$out"/lib/0ad
98− cp binaries/system/libCollada.so "$out"/lib/0ad/
99− ((${ toString withEditor })) && cp binaries/system/libAtlasUI.so "$out"/lib/0ad/
100−
101− # Create links to data files.
102− ln -s -t "$out"/share/0ad "${zeroadData}"/share/0ad/*
103−
104− # Copy icon.
105− mkdir -p "$out"/share/icons
106− cp build/resources/0ad.png "$out"/share/icons/
107−
108− # Copy/fix desktop item.
109− mkdir -p "$out"/share/applications
110− while read LINE; do
111− if [[ $LINE = "Exec=0ad" ]]; then
112− echo "Exec=$out/bin/zeroad"
113− elif [[ $LINE = "Icon=0ad" ]]; then
114− echo "Icon=$out/share/icons/0ad.png"
115− else
116− echo "$LINE"
117− fi
118− done <build/resources/0ad.desktop >"$out"/share/applications/0ad.desktop
119− '';
120−
121− meta = with stdenv.lib; {
122− description = "A free, open-source game of ancient warfare";
123− homepage = "http://wildfiregames.com/0ad/";
124− license = with licenses; [
125− gpl2 lgpl21 mit cc-by-sa-30
126− licenses.zlib # otherwise masked by pkgs.zlib
127− ];
128− platforms = [ "x86_64-linux" "i686-linux" ];
129− hydraPlatforms = []; # the data are too big (~1.5 GB)
130− };
131−}
14+in self