From 8fba774d113d434dd44e7fba012ada1f8db09d43 Mon Sep 17 00:00:00 2001 From: Daniel Perry Date: Fri, 10 Mar 2023 16:52:44 -0500 Subject: recastnavigation: 2021-03-05 -> 2023-01-02 Motivation: Needed for OpenMW Darwin support. Update contains build fixes for Darwin. --- pkgs/development/libraries/recastnavigation/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/recastnavigation/default.nix b/pkgs/development/libraries/recastnavigation/default.nix index 59f39986ffcdd..9920838aabaa5 100644 --- a/pkgs/development/libraries/recastnavigation/default.nix +++ b/pkgs/development/libraries/recastnavigation/default.nix @@ -4,13 +4,13 @@ stdenv.mkDerivation rec { pname = "recastai"; # use latest revision for the CMake build process and OpenMW # OpenMW use e75adf86f91eb3082220085e42dda62679f9a3ea - version = "unstable-2021-03-05"; + version = "unstable-2023-01-02"; src = fetchFromGitHub { owner = "recastnavigation"; repo = "recastnavigation"; - rev = "c5cbd53024c8a9d8d097a4371215e3342d2fdc87"; - sha256 = "sha256-QP3lMMFR6fiKQTksAkRL6X9yaoVz2xt4QSIP9g6piww="; + rev = "405cc095ab3a2df976a298421974a2af83843baf"; + sha256 = "sha256-WVzDI7+UuAl10Tm1Zjkea/FMk0cIe7pWg0iyFLbwAdI="; }; postPatch = '' -- cgit 1.4.1 From 254ff60f2799913411afc8436c5bf104608fa363 Mon Sep 17 00:00:00 2001 From: Daniel Perry Date: Fri, 10 Mar 2023 15:10:10 -0500 Subject: recastnavigation: fix for darwin build break Building on Darwin resulted in an error with not being able to find SDL header files. Looking through the remote repository code, it looks like it expects the SDL2.framework layout and not the Linux-style include directory layout. The main difference between these two layouts is whether or not the SDL header files are contained within a `SDL2` subdirectory. In the .framework file, the header files are located at `Headers/SDL_*.h`. On Linux, the headers are located under `include/SDL2/SDL_*.h`. When Nix builds SDL on Darwin, the output is in the Linux-style layout, while the recastnavigation CMakeLists.txt is expecting things to be in the .framework layout. The fix I made was to change the Darwin-specific `include_directories` directive which points to the Headers directory to instead point to the headers from the Nix store. --- pkgs/development/libraries/recastnavigation/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/recastnavigation/default.nix b/pkgs/development/libraries/recastnavigation/default.nix index 9920838aabaa5..8e0fe7947f440 100644 --- a/pkgs/development/libraries/recastnavigation/default.nix +++ b/pkgs/development/libraries/recastnavigation/default.nix @@ -20,6 +20,11 @@ stdenv.mkDerivation rec { substituteInPlace CMakeLists.txt \ --replace '\$'{exec_prefix}/'$'{CMAKE_INSTALL_LIBDIR} '$'{CMAKE_INSTALL_FULL_LIBDIR} \ --replace '\$'{prefix}/'$'{CMAKE_INSTALL_INCLUDEDIR} '$'{CMAKE_INSTALL_FULL_INCLUDEDIR} + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + # Expects SDL2.framework in specific location, which we don't have + # Change where SDL2 headers are searched for to match what we do have + substituteInPlace RecastDemo/CMakeLists.txt \ + --replace 'include_directories(''${SDL2_LIBRARY}/Headers)' 'include_directories(${SDL2.dev}/include/SDL2)' ''; doCheck = true; @@ -29,7 +34,6 @@ stdenv.mkDerivation rec { buildInputs = [ libGL SDL2 libGLU ]; meta = with lib; { - broken = stdenv.isDarwin; homepage = "https://github.com/recastnavigation/recastnavigation"; description = "Navigation-mesh Toolset for Games"; license = licenses.zlib; -- cgit 1.4.1 From 9618fea44dccddd15ecc4821e1171c7a1ae407cd Mon Sep 17 00:00:00 2001 From: Daniel Perry Date: Fri, 10 Mar 2023 19:39:31 -0500 Subject: unshield: add darwin to platforms Motivation: Required for Darwin build support for OpenMW. Unshield is a required package. No changes were required to build on Darwin. --- pkgs/tools/archivers/unshield/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/archivers/unshield/default.nix b/pkgs/tools/archivers/unshield/default.nix index 17d4e7854381c..b3d023df59b78 100644 --- a/pkgs/tools/archivers/unshield/default.nix +++ b/pkgs/tools/archivers/unshield/default.nix @@ -18,6 +18,6 @@ stdenv.mkDerivation rec { description = "Tool and library to extract CAB files from InstallShield installers"; homepage = "https://github.com/twogood/unshield"; license = licenses.mit; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; } -- cgit 1.4.1 From fb9bcc72fda42e7cf6e54f293b6b68b5f0c71aae Mon Sep 17 00:00:00 2001 From: Daniel Perry Date: Fri, 10 Mar 2023 19:32:06 -0500 Subject: openmw: add darwin support The OpenMW codebase already has Darwin build support within it, so porting it over to nixpkgs was something I wanted to try out. Issues encountered, in order: A few dependencies in nixpkgs were missing Darwin support. Details of those changes are in their respective commits. After the dependencies were building, the build first failed with a missing reference to VideoDecodeAcceleration, which was easily dealt with. Then the build succeeded! Job's done, success! Except OpenMW.app was nowhere to be found in the result folder. OpenMW-CS.app, however, was produced and appeared to be running correctly (though I will admit I didn't test it very much as I'm not very familiar). Going through OpenMW's CMakeLists.txt showed that a CMake define was needed, `OPENMW_OSX_DEPLOYMENT=ON`. This is what enables OpenMW.app to be built. Once the define was added, the build began to fail with missing plugins to OpenSceneGraph. Looking into that showed that OSG doesn't build certain plugins on Darwin due to the fact that their functionality is replicated by built- in system libraries. To save space, these libraries are not built on Darwin. OpenMW, however, requires these libraries to exist. I was familiar with the process of building OpenMW on Darwin already, due to having built it locally ahead of time, so I remembered that the OpenMW folks have a separate repository with Mac-specific patches. One of those patches is to OpenSceneGraph for this exact issue, which is now applied here. The next error was caused by `fixup_bundle` running from the OpenMW CMakeLists.txt, which appears to be broken in Darwin under Nix. Searching nixpkgs shows that others have worked around the issue by removing the call to `fixup_bundle` completely. At this point, the build passed and OpenMW.app was created and was executable! After the intro video played, it was clear that something wasn't working though. Every texture was completely pink, navigating the main menu was impossible. Looking at the console output showed that OpenSceneGraph was attempting to load dds textures, but the plugin for doing so could not be loaded. I looked at the plugin with `file` which showed the file was actually a bash script. It was setting some QT environment variables before calling the real plugin executable. I resolved this issue with setting `dontWrapQtApps`, as everything seems to work without it (even the QT-based apps like the Construction Set). --- pkgs/games/openmw/default.nix | 23 ++++++++++++++++++++++- pkgs/top-level/all-packages.nix | 4 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pkgs/games/openmw/default.nix b/pkgs/games/openmw/default.nix index 8df88c92ff1c4..3f6ce29c3a333 100644 --- a/pkgs/games/openmw/default.nix +++ b/pkgs/games/openmw/default.nix @@ -1,4 +1,5 @@ { lib +, stdenv , mkDerivation , fetchFromGitHub , fetchpatch @@ -16,6 +17,7 @@ , libXt , lz4 , recastnavigation +, VideoDecodeAcceleration }: let @@ -27,6 +29,15 @@ let rev = "bbe61c3bc510a4f5bb4aea21cce506519c2d24e6"; sha256 = "sha256-t3smLqstp7wWfi9HXJoBCek+3acqt/ySBYF8RJOG6Mo="; }; + patches = [ + (fetchpatch { + # For Darwin, OSG doesn't build some plugins as they're redundant with QuickTime. + # OpenMW doesn't like this, and expects them to be there. Apply their patch for it. + name = "darwin-osg-plugins-fix.patch"; + url = "https://gitlab.com/OpenMW/openmw-dep/-/raw/0abe3c9c3858211028d881d7706813d606335f72/macos/osg.patch"; + sha256 = "sha256-/CLRZofZHot8juH78VG1/qhTHPhy5DoPMN+oH8hC58U="; + }) + ]; }); bullet_openmw = bullet.overrideDerivation (old: rec { @@ -65,10 +76,16 @@ mkDerivation rec { postPatch = '' sed '1i#include ' -i components/myguiplatform/myguidatamanager.cpp # gcc12 + '' + lib.optionalString stdenv.isDarwin '' + # Don't fix Darwin app bundle + sed -i '/fixup_bundle/d' CMakeLists.txt ''; nativeBuildInputs = [ cmake pkg-config wrapQtAppsHook ]; + # If not set, OSG plugin .so files become shell scripts on Darwin. + dontWrapQtApps = true; + buildInputs = [ SDL2 boost @@ -81,12 +98,16 @@ mkDerivation rec { unshield lz4 recastnavigation + ] ++ lib.optionals stdenv.isDarwin [ + VideoDecodeAcceleration ]; cmakeFlags = [ # as of 0.46, openmw is broken with GLVND "-DOpenGL_GL_PREFERENCE=LEGACY" "-DOPENMW_USE_SYSTEM_RECASTNAVIGATION=1" + ] ++ lib.optionals stdenv.isDarwin [ + "-DOPENMW_OSX_DEPLOYMENT=ON" ]; meta = with lib; { @@ -94,6 +115,6 @@ mkDerivation rec { homepage = "https://openmw.org"; license = licenses.gpl3Plus; maintainers = with maintainers; [ abbradar marius851000 ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fe6f34f81192a..3644afb59585e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -35797,7 +35797,9 @@ with pkgs; openloco = pkgsi686Linux.callPackage ../games/openloco { }; - openmw = libsForQt5.callPackage ../games/openmw { }; + openmw = libsForQt5.callPackage ../games/openmw { + inherit (darwin.apple_sdk.frameworks) VideoDecodeAcceleration; + }; openmw-tes3mp = libsForQt5.callPackage ../games/openmw/tes3mp.nix { }; -- cgit 1.4.1