| 
									
										
										
										
											2018-07-21 00:44:44 +00:00
										 |  |  | { stdenv, lib, perl, fetchurl, python2 | 
					
						
							| 
									
										
										
										
											2021-01-17 12:49:22 +07:00
										 |  |  | , pkg-config, spidermonkey_38, boost, icu, libxml2, libpng, libsodium | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | , libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc | 
					
						
							| 
									
										
										
										
											2019-11-10 16:44:34 +00:00
										 |  |  | , openal, libGLU, libGL, xorgproto, libX11, libXcursor, nspr, SDL2 | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | , gloox, nvidia-texture-tools | 
					
						
							|  |  |  | , withEditor ? true, wxGTK ? null | 
					
						
							|  |  |  | }: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | assert withEditor -> wxGTK != null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | stdenv.mkDerivation rec { | 
					
						
							| 
									
										
										
										
											2019-08-15 12:41:18 +00:00
										 |  |  |   pname = "0ad"; | 
					
						
							| 
									
										
										
										
											2019-01-10 21:03:08 +01:00
										 |  |  |   version = "0.0.23b"; | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   src = fetchurl { | 
					
						
							|  |  |  |     url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-build.tar.xz"; | 
					
						
							| 
									
										
										
										
											2019-01-10 21:03:08 +01:00
										 |  |  |     sha256 = "0draa53xg69i5qhqym85658m45xhwkbiimaldj4sr3703rjgggq1"; | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-17 12:49:22 +07:00
										 |  |  |   nativeBuildInputs = [ python2 perl pkg-config ]; | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   buildInputs = [ | 
					
						
							| 
									
										
										
										
											2016-11-11 01:32:22 +03:00
										 |  |  |     spidermonkey_38 boost icu libxml2 libpng libjpeg | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |     zlib curl libogg libvorbis enet miniupnpc openal | 
					
						
							| 
									
										
										
										
											2019-11-10 16:44:34 +00:00
										 |  |  |     libGLU libGL xorgproto libX11 libXcursor nspr SDL2 gloox | 
					
						
							| 
									
										
										
										
											2018-05-21 03:32:03 +08:00
										 |  |  |     nvidia-texture-tools libsodium | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |   ] ++ lib.optional withEditor wxGTK; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-30 12:34:47 +01:00
										 |  |  |   NIX_CFLAGS_COMPILE = toString [ | 
					
						
							| 
									
										
										
										
											2018-12-31 04:40:47 +01:00
										 |  |  |     "-I${xorgproto}/include/X11" | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |     "-I${libX11.dev}/include/X11" | 
					
						
							|  |  |  |     "-I${libXcursor.dev}/include/X11" | 
					
						
							|  |  |  |     "-I${SDL2}/include/SDL2" | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 12:05:33 +01:00
										 |  |  |   patches = [ | 
					
						
							|  |  |  |     ./rootdir_env.patch | 
					
						
							|  |  |  |     # Fixes build with spidermonkey-38.8.0, includes the minor version check: | 
					
						
							|  |  |  |     # https://src.fedoraproject.org/rpms/0ad/c/26dc1657f6e3c0ad9f1180ca38cd79b933ef0c8b | 
					
						
							|  |  |  |     (fetchurl { | 
					
						
							| 
									
										
										
										
											2020-03-31 21:11:51 -04:00
										 |  |  |       url = "https://src.fedoraproject.org/rpms/0ad/raw/26dc1657f6e3c0ad9f1180ca38cd79b933ef0c8b/f/0ad-mozjs-incompatible.patch"; | 
					
						
							| 
									
										
										
										
											2018-12-18 12:05:33 +01:00
										 |  |  |       sha256 = "1rzpaalcrzihsgvlk3nqd87n2kxjldlwvb3qp5fcd5ffzr6k90wa"; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   ]; | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   configurePhase = ''
 | 
					
						
							|  |  |  |     # Delete shipped libraries which we don't need. | 
					
						
							|  |  |  |     rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-18 22:50:56 -08:00
										 |  |  |     # Workaround invalid pkg-config name for mozjs | 
					
						
							|  |  |  |     mkdir pkg-config | 
					
						
							|  |  |  |     ln -s ${spidermonkey_38}/lib/pkgconfig/* pkg-config/mozjs-38.pc
 | 
					
						
							| 
									
										
										
										
											2021-01-20 17:42:39 +01:00
										 |  |  |     PKG_CONFIG_PATH="$PWD/pkg-config:$PKG_CONFIG_PATH" | 
					
						
							| 
									
										
										
										
											2016-11-11 01:32:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |     # Update Makefiles | 
					
						
							|  |  |  |     pushd build/workspaces | 
					
						
							|  |  |  |     ./update-workspaces.sh \ | 
					
						
							|  |  |  |       --with-system-nvtt \ | 
					
						
							| 
									
										
										
										
											2016-11-11 01:32:22 +03:00
										 |  |  |       --with-system-mozjs38 \ | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03: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-21 03:32:03 +08:00
										 |  |  |     install -Dm755 -t $out/share/0ad/data/l10n binaries/data/l10n/*
 | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Copy libraries. | 
					
						
							| 
									
										
										
										
											2018-05-21 03:32:03 +08:00
										 |  |  |     install -Dm644 -t $out/lib/0ad        binaries/system/*.so
 | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Copy icon. | 
					
						
							| 
									
										
										
										
											2018-05-21 03:32:03 +08:00
										 |  |  |     install -D build/resources/0ad.png     $out/share/icons/hicolor/128x128/0ad.png | 
					
						
							|  |  |  |     install -D build/resources/0ad.desktop $out/share/applications/0ad.desktop | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |   '';
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-11 08:54:33 +01:00
										 |  |  |   meta = with lib; { | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |     description = "A free, open-source game of ancient warfare"; | 
					
						
							| 
									
										
										
										
											2017-10-22 22:19:28 +00:00
										 |  |  |     homepage = "https://play0ad.com/"; | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |     license = with licenses; [ | 
					
						
							|  |  |  |       gpl2 lgpl21 mit cc-by-sa-30 | 
					
						
							|  |  |  |       licenses.zlib # otherwise masked by pkgs.zlib | 
					
						
							|  |  |  |     ]; | 
					
						
							| 
									
										
										
										
											2017-03-30 16:22:49 +02:00
										 |  |  |     platforms = subtractLists platforms.i686 platforms.linux; | 
					
						
							| 
									
										
										
										
											2016-11-03 16:43:42 +03:00
										 |  |  |   }; | 
					
						
							|  |  |  | } |