openmw: refactor
The usual code modernisation (finalAttrs, no with lib; in meta, no pname interpolation), and CMAKE variables now use lib.cmake*. Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitLab,
|
||||
fetchpatch,
|
||||
|
||||
SDL2,
|
||||
boost,
|
||||
bullet,
|
||||
cmake,
|
||||
collada-dom,
|
||||
ffmpeg,
|
||||
libXt,
|
||||
lua,
|
||||
luajit,
|
||||
lz4,
|
||||
mygui,
|
||||
openal,
|
||||
openscenegraph,
|
||||
pkg-config,
|
||||
qt6Packages,
|
||||
recastnavigation,
|
||||
unshield,
|
||||
yaml-cpp,
|
||||
|
||||
GLPreference ? "GLVND",
|
||||
}:
|
||||
let
|
||||
inherit (stdenv.hostPlatform) isDarwin isLinux isAarch64;
|
||||
isAarch64Linux = isLinux && isAarch64;
|
||||
in
|
||||
assert lib.assertOneOf "GLPreference" GLPreference [
|
||||
"GLVND"
|
||||
"LEGACY"
|
||||
];
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "openmw";
|
||||
version = "0.49.0";
|
||||
|
||||
__structuredAttrs = true;
|
||||
strictDeps = true;
|
||||
|
||||
osg' = (openscenegraph.override { colladaSupport = true; }).overrideAttrs (oldAttrs: {
|
||||
patches = (oldAttrs.patches or [ ]) ++ [
|
||||
(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/1305497c009dc0e7a6a70fe14f0a2f92b96cbcb4/macos/osg.patch";
|
||||
hash = "sha256-G8Y+fnR6FRGxECWrei/Ixch3A3PkRfH6b5q9iawsSCY=";
|
||||
})
|
||||
];
|
||||
cmakeFlags =
|
||||
(oldAttrs.cmakeFlags or [ ])
|
||||
++ [
|
||||
"-Wno-dev"
|
||||
(lib.cmakeFeature "OpenGL_GL_PREFERENCE" GLPreference)
|
||||
(lib.cmakeBool "BUILD_OSG_PLUGINS_BY_DEFAULT" false)
|
||||
(lib.cmakeBool "BUILD_OSG_DEPRECATED_SERIALIZERS" false)
|
||||
]
|
||||
++ (map (plugin: lib.cmakeBool "BUILD_OSG_PLUGIN_${plugin}" true) [
|
||||
"BMP"
|
||||
"DAE"
|
||||
"DDS"
|
||||
"FREETYPE"
|
||||
"JPEG"
|
||||
"OSG"
|
||||
"PNG"
|
||||
"TGA"
|
||||
]);
|
||||
});
|
||||
|
||||
bullet' = bullet.overrideAttrs (oldAttrs: {
|
||||
cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [
|
||||
"-Wno-dev"
|
||||
(lib.cmakeFeature "OpenGL_GL_PREFERENCE" GLPreference)
|
||||
(lib.cmakeBool "USE_DOUBLE_PRECISION" true)
|
||||
(lib.cmakeBool "BULLET2_MULTITHREADING" true)
|
||||
];
|
||||
});
|
||||
|
||||
src = fetchFromGitLab {
|
||||
owner = "OpenMW";
|
||||
repo = "openmw";
|
||||
tag = "openmw-${finalAttrs.version}";
|
||||
hash = "sha256-Eyjn3jPpo0d7XENg0Ea/3MN60lZBSUAMkz1UtTiIP80=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12
|
||||
''
|
||||
# Don't fix Darwin app bundle
|
||||
+ lib.optionalString isDarwin ''
|
||||
sed -i '/fixup_bundle/d' CMakeLists.txt
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
]
|
||||
++ (with qt6Packages; [
|
||||
wrapQtAppsHook
|
||||
]);
|
||||
|
||||
# If not set, OSG plugin .so files become shell scripts on Darwin.
|
||||
dontWrapQtApps = isDarwin;
|
||||
|
||||
buildInputs = [
|
||||
SDL2
|
||||
boost
|
||||
collada-dom
|
||||
ffmpeg
|
||||
libXt
|
||||
(if isAarch64Linux then lua else luajit)
|
||||
lz4
|
||||
mygui
|
||||
openal
|
||||
recastnavigation
|
||||
unshield
|
||||
yaml-cpp
|
||||
]
|
||||
++ (with qt6Packages; [
|
||||
qttools
|
||||
])
|
||||
++ (with finalAttrs; [
|
||||
bullet'
|
||||
osg'
|
||||
]);
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeFeature "OpenGL_GL_PREFERENCE" GLPreference)
|
||||
(lib.cmakeBool "USE_LUAJIT" (!isAarch64Linux))
|
||||
(lib.cmakeBool "OPENMW_USE_SYSTEM_RECASTNAVIGATION" true)
|
||||
(lib.cmakeBool "OPENMW_OSX_DEPLOYMENT" isDarwin)
|
||||
];
|
||||
|
||||
meta = {
|
||||
description = "Unofficial open source engine reimplementation of the game Morrowind";
|
||||
changelog = "https://gitlab.com/OpenMW/openmw/-/blob/${finalAttrs.src.tag}/CHANGELOG.md";
|
||||
homepage = "https://openmw.org";
|
||||
license = lib.licenses.gpl3Plus;
|
||||
maintainers = with lib.maintainers; [
|
||||
marius851000
|
||||
sigmasquadron
|
||||
];
|
||||
platforms = with lib.platforms; linux ++ darwin ++ windows;
|
||||
# Nixpkgs' NT infrastructure is currently incapable of building this.
|
||||
badPlatforms = lib.platforms.windows;
|
||||
};
|
||||
})
|
||||
@@ -1,130 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitLab,
|
||||
fetchpatch,
|
||||
|
||||
SDL2,
|
||||
boost,
|
||||
bullet,
|
||||
cmake,
|
||||
ffmpeg,
|
||||
libXt,
|
||||
luajit,
|
||||
lz4,
|
||||
mygui,
|
||||
openal,
|
||||
openscenegraph,
|
||||
pkg-config,
|
||||
qttools,
|
||||
recastnavigation,
|
||||
unshield,
|
||||
wrapQtAppsHook,
|
||||
yaml-cpp,
|
||||
}:
|
||||
|
||||
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/1305497c009dc0e7a6a70fe14f0a2f92b96cbcb4/macos/osg.patch";
|
||||
sha256 = "sha256-G8Y+fnR6FRGxECWrei/Ixch3A3PkRfH6b5q9iawsSCY=";
|
||||
})
|
||||
];
|
||||
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"
|
||||
]);
|
||||
});
|
||||
|
||||
bullet' = bullet.overrideDerivation (old: {
|
||||
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
|
||||
"-Wno-dev"
|
||||
"-DOpenGL_GL_PREFERENCE=${GL}"
|
||||
"-DUSE_DOUBLE_PRECISION=ON"
|
||||
"-DBULLET2_MULTITHREADING=ON"
|
||||
];
|
||||
});
|
||||
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "openmw";
|
||||
version = "0.49.0";
|
||||
|
||||
src = fetchFromGitLab {
|
||||
owner = "OpenMW";
|
||||
repo = "openmw";
|
||||
rev = "${pname}-${version}";
|
||||
hash = "sha256-Eyjn3jPpo0d7XENg0Ea/3MN60lZBSUAMkz1UtTiIP80=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12
|
||||
''
|
||||
+ lib.optionalString stdenv.hostPlatform.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 = stdenv.hostPlatform.isDarwin;
|
||||
|
||||
buildInputs = [
|
||||
SDL2
|
||||
boost
|
||||
bullet'
|
||||
ffmpeg
|
||||
libXt
|
||||
luajit
|
||||
lz4
|
||||
mygui
|
||||
openal
|
||||
osg'
|
||||
qttools
|
||||
recastnavigation
|
||||
unshield
|
||||
yaml-cpp
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DOpenGL_GL_PREFERENCE=${GL}"
|
||||
"-DOPENMW_USE_SYSTEM_RECASTNAVIGATION=1"
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
"-DOPENMW_OSX_DEPLOYMENT=ON"
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Unofficial open source engine reimplementation of the game Morrowind";
|
||||
homepage = "https://openmw.org";
|
||||
license = licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [
|
||||
marius851000
|
||||
];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
}
|
||||
@@ -14124,9 +14124,7 @@ with pkgs;
|
||||
|
||||
openloco = pkgsi686Linux.callPackage ../games/openloco { };
|
||||
|
||||
openmw = libsForQt5.callPackage ../games/openmw { };
|
||||
|
||||
openmw-tes3mp = libsForQt5.callPackage ../games/openmw/tes3mp.nix { };
|
||||
openmw-tes3mp = libsForQt5.callPackage ../games/tes3mp { };
|
||||
|
||||
openraPackages_2019 = import ../games/openra_2019 {
|
||||
inherit lib;
|
||||
|
||||
Reference in New Issue
Block a user