From 9815ef3639ac523d077805f211d5b09dccd7f794 Mon Sep 17 00:00:00 2001 From: Daniel Nagy Date: Mon, 22 Feb 2021 21:06:43 +0100 Subject: [PATCH 1/2] zeroad: 0.0.23b -> 0.0.24b --- pkgs/games/0ad/data.nix | 2 +- pkgs/games/0ad/game.nix | 57 +++++++++++++++++--------------- pkgs/games/0ad/rootdir_env.patch | 38 --------------------- pkgs/top-level/all-packages.nix | 1 - 4 files changed, 32 insertions(+), 66 deletions(-) delete mode 100644 pkgs/games/0ad/rootdir_env.patch diff --git a/pkgs/games/0ad/data.nix b/pkgs/games/0ad/data.nix index 1bebf922c48d..5cb28b3f3bd6 100644 --- a/pkgs/games/0ad/data.nix +++ b/pkgs/games/0ad/data.nix @@ -6,7 +6,7 @@ stdenv.mkDerivation rec { src = fetchurl { url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-data.tar.xz"; - sha256 = "04x7729hk6zw1xj3n4s4lvaviijsnbjf5rhzvjxlr5fygvg4l6z1"; + sha256 = "0b53jzl64i49rk3n3c3x0hibwbl7vih2xym8jq5s56klg61qdxa1"; }; installPhase = '' diff --git a/pkgs/games/0ad/game.nix b/pkgs/games/0ad/game.nix index 1ba975aa8854..3543121071ed 100644 --- a/pkgs/games/0ad/game.nix +++ b/pkgs/games/0ad/game.nix @@ -1,29 +1,42 @@ -{ stdenv, lib, perl, fetchurl, python2 -, pkg-config, spidermonkey_38, boost, icu, libxml2, libpng, libsodium +{ stdenv, lib, perl, fetchurl, python2, fmt, libidn +, pkg-config, spidermonkey_78, boost, icu, libxml2, libpng, libsodium , libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc , openal, libGLU, libGL, xorgproto, libX11, libXcursor, nspr, SDL2 -, gloox, nvidia-texture-tools -, withEditor ? true, wxGTK ? null +, gloox, nvidia-texture-tools, zeroad-data +, withEditor ? true, wxGTK }: -assert withEditor -> wxGTK != null; +# 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"; + }; + }); +in stdenv.mkDerivation rec { pname = "0ad"; - version = "0.0.23b"; + version = "0.0.24b"; src = fetchurl { url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-build.tar.xz"; - sha256 = "0draa53xg69i5qhqym85658m45xhwkbiimaldj4sr3703rjgggq1"; + sha256 = "1a1py45hkh2cswi09vbf9chikgxdv9xplsmg6sv6xhdznv4j6p1j"; }; nativeBuildInputs = [ python2 perl pkg-config ]; buildInputs = [ - spidermonkey_38 boost icu libxml2 libpng libjpeg - zlib curl libogg libvorbis enet miniupnpc openal + spidermonkey_78_6 boost icu libxml2 libpng libjpeg + zlib curl libogg libvorbis enet miniupnpc openal libidn libGLU libGL xorgproto libX11 libXcursor nspr SDL2 gloox - nvidia-texture-tools libsodium + nvidia-texture-tools libsodium fmt ] ++ lib.optional withEditor wxGTK; NIX_CFLAGS_COMPILE = toString [ @@ -31,35 +44,22 @@ stdenv.mkDerivation rec { "-I${libX11.dev}/include/X11" "-I${libXcursor.dev}/include/X11" "-I${SDL2}/include/SDL2" - ]; - - 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 { - url = "https://src.fedoraproject.org/rpms/0ad/raw/26dc1657f6e3c0ad9f1180ca38cd79b933ef0c8b/f/0ad-mozjs-incompatible.patch"; - sha256 = "1rzpaalcrzihsgvlk3nqd87n2kxjldlwvb3qp5fcd5ffzr6k90wa"; - }) + "-I${fmt.dev}/include" ]; configurePhase = '' # Delete shipped libraries which we don't need. rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey} - # Workaround invalid pkg-config name for mozjs - mkdir pkg-config - ln -s ${spidermonkey_38}/lib/pkgconfig/* pkg-config/mozjs-38.pc - PKG_CONFIG_PATH="$PWD/pkg-config:$PKG_CONFIG_PATH" - # Update Makefiles pushd build/workspaces ./update-workspaces.sh \ --with-system-nvtt \ - --with-system-mozjs38 \ + --with-system-mozjs \ ${lib.optionalString withEditor "--enable-atlas"} \ --bindir="$out"/bin \ --libdir="$out"/lib/0ad \ + --datadir="$out"/share/0ad/data \ --without-tests \ -j $NIX_BUILD_CORES popd @@ -82,6 +82,11 @@ stdenv.mkDerivation rec { # Copy l10n data. install -Dm755 -t $out/share/0ad/data/l10n binaries/data/l10n/* + # Link in game data from package + ln -s ${zeroad-data}/share/0ad/data/config $out/share/0ad/data/config + ln -s ${zeroad-data}/share/0ad/data/mods $out/share/0ad/data/mods + ln -s ${zeroad-data}/share/0ad/data/tools $out/share/0ad/data/tools + # Copy libraries. install -Dm644 -t $out/lib/0ad binaries/system/*.so diff --git a/pkgs/games/0ad/rootdir_env.patch b/pkgs/games/0ad/rootdir_env.patch deleted file mode 100644 index c001473e5104..000000000000 --- a/pkgs/games/0ad/rootdir_env.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff -ru3 0ad-0.0.20-alpha/source/ps/GameSetup/Paths.cpp 0ad-0.0.20-alpha-new/source/ps/GameSetup/Paths.cpp ---- 0ad-0.0.20-alpha/source/ps/GameSetup/Paths.cpp 2015-02-14 04:45:13.000000000 +0300 -+++ 0ad-0.0.20-alpha-new/source/ps/GameSetup/Paths.cpp 2016-11-03 16:23:47.241514876 +0300 -@@ -155,32 +155,8 @@ - - /*static*/ OsPath Paths::Root(const OsPath& argv0) - { --#if OS_ANDROID -- return OsPath("/sdcard/0ad"); // TODO: this is kind of bogus --#else -- -- // get full path to executable -- OsPath pathname = sys_ExecutablePathname(); // safe, but requires OS-specific implementation -- if(pathname.empty()) // failed, use argv[0] instead -- { -- errno = 0; -- pathname = wrealpath(argv0); -- if(pathname.empty()) -- WARN_IF_ERR(StatusFromErrno()); -- } -- -- // make sure it's valid -- if(!FileExists(pathname)) -- { -- LOGERROR("Cannot find executable (expected at '%s')", pathname.string8()); -- WARN_IF_ERR(StatusFromErrno()); -- } -- -- for(size_t i = 0; i < 2; i++) // remove "system/name.exe" -- pathname = pathname.Parent(); -- return pathname; -- --#endif -+ UNUSED2(argv0); -+ return getenv("ZEROAD_ROOTDIR"); - } - - /*static*/ OsPath Paths::RootData(const OsPath& argv0) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3444df357987..e47951b5e92b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -27815,7 +27815,6 @@ in zeroadPackages = dontRecurseIntoAttrs (callPackage ../games/0ad { wxGTK = wxGTK30; - stdenv = gcc9Stdenv; }); zeroad = zeroadPackages.zeroad; From a410e5dc477f4a6c5f1683513b4406ad14d10718 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Sat, 20 Mar 2021 15:34:10 +0100 Subject: [PATCH 2/2] zeroad: fix build of spidermonkey derivation --- pkgs/games/0ad/game.nix | 3 +++ pkgs/games/0ad/spidermonkey-cargo-toml.patch | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 pkgs/games/0ad/spidermonkey-cargo-toml.patch diff --git a/pkgs/games/0ad/game.nix b/pkgs/games/0ad/game.nix index 3543121071ed..bb3b7c0138af 100644 --- a/pkgs/games/0ad/game.nix +++ b/pkgs/games/0ad/game.nix @@ -19,6 +19,9 @@ let url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz"; sha256 = "0lyg65v380j8i2lrylwz8a5ya80822l8vcnlx3dfqpd3s6zzjsay"; }; + patches = (old.patches or []) ++ [ + ./spidermonkey-cargo-toml.patch + ]; }); in stdenv.mkDerivation rec { diff --git a/pkgs/games/0ad/spidermonkey-cargo-toml.patch b/pkgs/games/0ad/spidermonkey-cargo-toml.patch new file mode 100644 index 000000000000..4cb8c3735dbd --- /dev/null +++ b/pkgs/games/0ad/spidermonkey-cargo-toml.patch @@ -0,0 +1,15 @@ +diff --git a/Cargo.toml b/Cargo.toml +index 6f6199ab26..c3f92db9d8 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -68,8 +68,8 @@ panic = "abort" + libudev-sys = { path = "dom/webauthn/libudev-sys" } + packed_simd = { git = "https://github.com/hsivonen/packed_simd", rev="3541e3818fdc7c2a24f87e3459151a4ce955a67a" } + rlbox_lucet_sandbox = { git = "https://github.com/PLSysSec/rlbox_lucet_sandbox/", rev="d510da5999a744c563b0acd18056069d1698273f" } +-nix = { git = "https://github.com/shravanrn/nix/", branch = "r0.13.1", rev="4af6c367603869a30fddb5ffb0aba2b9477ba92e" } +-spirv_cross = { git = "https://github.com/kvark/spirv_cross", branch = "wgpu3", rev = "20191ad2f370afd6d247edcb9ff9da32d3bedb9c" } ++nix = { git = "https://github.com/shravanrn/nix/", branch = "r0.13.1" } ++spirv_cross = { git = "https://github.com/kvark/spirv_cross", branch = "wgpu3" } + # failure's backtrace feature might break our builds, see bug 1608157. + failure = { git = "https://github.com/badboy/failure", rev = "64af847bc5fdcb6d2438bec8a6030812a80519a5" } + failure_derive = { git = "https://github.com/badboy/failure", rev = "64af847bc5fdcb6d2438bec8a6030812a80519a5" }