1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 fetchpatch,
6 cmake,
7 pkg-config,
8 wrapQtAppsHook,
9 SDL2,
10 boost,
11 bullet,
12 # Please unpin this on the next OpenMW release.
13 ffmpeg_6,
14 libXt,
15 luajit,
16 lz4,
17 mygui,
18 openal,
19 openscenegraph,
20 recastnavigation,
21 unshield,
22 yaml-cpp,
23}:
24
25let
26 GL = "GLVND"; # or "LEGACY";
27
28 osg' = (openscenegraph.override { colladaSupport = true; }).overrideDerivation (old: {
29 patches = [
30 (fetchpatch {
31 # Darwin: Without this patch, OSG won't build osgdb_png.so, which is required by OpenMW.
32 name = "darwin-osg-plugins-fix.patch";
33 url = "https://gitlab.com/OpenMW/openmw-dep/-/raw/0abe3c9c3858211028d881d7706813d606335f72/macos/osg.patch";
34 sha256 = "sha256-/CLRZofZHot8juH78VG1/qhTHPhy5DoPMN+oH8hC58U=";
35 })
36 ];
37 cmakeFlags =
38 (old.cmakeFlags or [ ])
39 ++ [
40 "-Wno-dev"
41 "-DOpenGL_GL_PREFERENCE=${GL}"
42 "-DBUILD_OSG_PLUGINS_BY_DEFAULT=0"
43 "-DBUILD_OSG_DEPRECATED_SERIALIZERS=0"
44 ]
45 ++ (map (e: "-DBUILD_OSG_PLUGIN_${e}=1") [
46 "BMP"
47 "DAE"
48 "DDS"
49 "FREETYPE"
50 "JPEG"
51 "OSG"
52 "PNG"
53 "TGA"
54 ]);
55 });
56
57 bullet' = bullet.overrideDerivation (old: {
58 cmakeFlags = (old.cmakeFlags or [ ]) ++ [
59 "-Wno-dev"
60 "-DOpenGL_GL_PREFERENCE=${GL}"
61 "-DUSE_DOUBLE_PRECISION=ON"
62 "-DBULLET2_MULTITHREADING=ON"
63 ];
64 });
65
66in
67stdenv.mkDerivation rec {
68 pname = "openmw";
69 version = "0.48.0";
70
71 src = fetchFromGitLab {
72 owner = "OpenMW";
73 repo = "openmw";
74 rev = "${pname}-${version}";
75 hash = "sha256-zkjVt3GfQZsFXl2Ht3lCuQtDMYQWxhdFO4aGSb3rsyo=";
76 };
77
78 patches = [ ./0001-function-inclusion-fixes-for-gcc14.patch ];
79
80 postPatch = ''
81 sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12
82 ''
83 + lib.optionalString stdenv.hostPlatform.isDarwin ''
84 # Don't fix Darwin app bundle
85 sed -i '/fixup_bundle/d' CMakeLists.txt
86 '';
87
88 nativeBuildInputs = [
89 cmake
90 pkg-config
91 wrapQtAppsHook
92 ];
93
94 # If not set, OSG plugin .so files become shell scripts on Darwin.
95 dontWrapQtApps = stdenv.hostPlatform.isDarwin;
96
97 buildInputs = [
98 SDL2
99 boost
100 bullet'
101 ffmpeg_6
102 libXt
103 luajit
104 lz4
105 mygui
106 openal
107 osg'
108 recastnavigation
109 unshield
110 yaml-cpp
111 ];
112
113 cmakeFlags = [
114 "-DOpenGL_GL_PREFERENCE=${GL}"
115 "-DOPENMW_USE_SYSTEM_RECASTNAVIGATION=1"
116 ]
117 ++ lib.optionals stdenv.hostPlatform.isDarwin [
118 "-DOPENMW_OSX_DEPLOYMENT=ON"
119 ];
120
121 meta = with lib; {
122 description = "Unofficial open source engine reimplementation of the game Morrowind";
123 homepage = "https://openmw.org";
124 license = licenses.gpl3Plus;
125 maintainers = with maintainers; [
126 abbradar
127 marius851000
128 ];
129 platforms = platforms.linux ++ platforms.darwin;
130 };
131}