nixpkgs/pkgs/games/openmw/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
2.6 KiB
Nix
Raw Normal View History

2021-05-19 03:30:30 +02:00
{ lib
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).
2023-03-11 01:32:06 +01:00
, stdenv
, fetchFromGitLab
2022-04-20 05:45:37 +02:00
, fetchpatch
2021-05-19 03:30:30 +02:00
, cmake
, pkg-config
, wrapQtAppsHook
, SDL2
, CoreMedia
, VideoToolbox
, VideoDecodeAcceleration
, boost
2021-05-19 03:30:30 +02:00
, bullet
, ffmpeg
, libXt
, luajit
2021-11-09 20:56:25 +01:00
, lz4
, mygui
, openal
, openscenegraph
2021-11-09 20:56:25 +01:00
, recastnavigation
, unshield
, yaml-cpp
2021-05-19 03:30:30 +02:00
}:
2015-09-26 20:00:36 +02:00
let
GL = "GLVND"; # or "LEGACY";
osg' = (openscenegraph.override { colladaSupport = true; }).overrideDerivation (old: {
patches = [
(fetchpatch {
# Darwin: Without this patch, OSG won't build osgdb_png.so, which is required by OpenMW.
name = "darwin-osg-plugins-fix.patch";
url = "https://gitlab.com/OpenMW/openmw-dep/-/raw/0abe3c9c3858211028d881d7706813d606335f72/macos/osg.patch";
sha256 = "sha256-/CLRZofZHot8juH78VG1/qhTHPhy5DoPMN+oH8hC58U=";
})
];
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
"-Wno-dev"
"-DOpenGL_GL_PREFERENCE=${GL}"
"-DBUILD_OSG_PLUGINS_BY_DEFAULT=0"
"-DBUILD_OSG_DEPRECATED_SERIALIZERS=0"
] ++ (map (e: "-DBUILD_OSG_PLUGIN_${e}=1") [ "BMP" "DAE" "DDS" "FREETYPE" "JPEG" "OSG" "PNG" "TGA" ]);
});
2021-11-09 20:56:25 +01:00
bullet' = bullet.overrideDerivation (old: {
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
"-Wno-dev"
"-DOpenGL_GL_PREFERENCE=${GL}"
2021-11-09 20:56:25 +01:00
"-DUSE_DOUBLE_PRECISION=ON"
"-DBULLET2_MULTITHREADING=ON"
];
});
2021-05-19 03:30:30 +02:00
in
stdenv.mkDerivation rec {
pname = "openmw";
version = "0.48.0";
2015-09-26 20:00:36 +02:00
src = fetchFromGitLab {
2015-09-26 20:00:36 +02:00
owner = "OpenMW";
repo = "openmw";
rev = "${pname}-${version}";
hash = "sha256-zkjVt3GfQZsFXl2Ht3lCuQtDMYQWxhdFO4aGSb3rsyo=";
2015-09-26 20:00:36 +02:00
};
postPatch = ''
sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12
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).
2023-03-11 01:32:06 +01:00
'' + lib.optionalString stdenv.isDarwin ''
# Don't fix Darwin app bundle
sed -i '/fixup_bundle/d' CMakeLists.txt
'';
nativeBuildInputs = [ cmake pkg-config wrapQtAppsHook ];
2021-05-19 03:30:30 +02:00
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).
2023-03-11 01:32:06 +01:00
# If not set, OSG plugin .so files become shell scripts on Darwin.
dontWrapQtApps = stdenv.isDarwin;
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).
2023-03-11 01:32:06 +01:00
2021-05-19 03:30:30 +02:00
buildInputs = [
SDL2
boost
bullet'
2021-05-19 03:30:30 +02:00
ffmpeg
libXt
luajit
lz4
2021-05-19 03:30:30 +02:00
mygui
openal
osg'
2021-11-09 20:56:25 +01:00
recastnavigation
unshield
yaml-cpp
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).
2023-03-11 01:32:06 +01:00
] ++ lib.optionals stdenv.isDarwin [
CoreMedia
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).
2023-03-11 01:32:06 +01:00
VideoDecodeAcceleration
VideoToolbox
2021-05-19 03:30:30 +02:00
];
2019-03-14 15:53:34 +01:00
2019-03-13 08:33:02 +01:00
cmakeFlags = [
"-DOpenGL_GL_PREFERENCE=${GL}"
2021-11-09 20:56:25 +01:00
"-DOPENMW_USE_SYSTEM_RECASTNAVIGATION=1"
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).
2023-03-11 01:32:06 +01:00
] ++ lib.optionals stdenv.isDarwin [
"-DOPENMW_OSX_DEPLOYMENT=ON"
2019-03-13 08:33:02 +01:00
];
2015-09-26 20:00:36 +02:00
meta = with lib; {
2015-09-26 20:00:36 +02:00
description = "An unofficial open source engine reimplementation of the game Morrowind";
2021-11-09 20:56:25 +01:00
homepage = "https://openmw.org";
license = licenses.gpl3Plus;
2021-11-09 20:56:25 +01:00
maintainers = with maintainers; [ abbradar marius851000 ];
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).
2023-03-11 01:32:06 +01:00
platforms = platforms.linux ++ platforms.darwin;
2015-09-26 20:00:36 +02:00
};
}