Unverified Commit b3f3b2d5 authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

ut-1999: fix build in darwin build sandbox (#446726)

parents d9d0320c 5c40bc66
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  requireFile,
  autoPatchelfHook,
  undmg,
  fetchurl,
@@ -18,6 +17,8 @@
  openal,
  libmpg123,
  libxmp,
  libiconv,
  darwin,
}:

let
@@ -84,6 +85,9 @@ stdenv.mkDerivation (finalAttrs: {
    libmpg123
    libxmp
    stdenv.cc.cc
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    libiconv
  ];

  nativeBuildInputs =
@@ -94,6 +98,7 @@ stdenv.mkDerivation (finalAttrs: {
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      makeWrapper
      undmg
      darwin.autoSignDarwinBinariesHook
    ];

  installPhase =
@@ -116,6 +121,15 @@ stdenv.mkDerivation (finalAttrs: {
      cp -r "UnrealTournament.app" $out/Applications/
      makeWrapper $out/Applications/UnrealTournament.app/Contents/MacOS/UnrealTournament \
        $out/bin/${finalAttrs.meta.mainProgram}
      # If the darwin build sandbox is enabled, system libiconv is not available
      # https://github.com/OldUnreal/UnrealTournamentPatches/issues/1902
      # Even though ut1999 is able to unpack the map files at runtime, upstream advised to still do it at install time
      # which is why the UCC binary is fixed to access a copy of iconv from the nix store
      install_name_tool -change /usr/lib/libiconv.2.dylib \
        ${libiconv}/lib/libiconv.2.dylib \
        $out/Applications/UnrealTournament.app/Contents/MacOS/UCC
      # Needs manual re-signing, as UCC is used during the build, and the auto signer is part of the fixup phase
      signDarwinBinariesInAllOutputs
    ''
    + ''
      chmod -R 755 $out