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>

+150 -133
+149
pkgs/by-name/op/openmw/package.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchFromGitLab, 5 + fetchpatch, 6 + 7 + SDL2, 8 + boost, 9 + bullet, 10 + cmake, 11 + collada-dom, 12 + ffmpeg, 13 + libXt, 14 + lua, 15 + luajit, 16 + lz4, 17 + mygui, 18 + openal, 19 + openscenegraph, 20 + pkg-config, 21 + qt6Packages, 22 + recastnavigation, 23 + unshield, 24 + yaml-cpp, 25 + 26 + GLPreference ? "GLVND", 27 + }: 28 + let 29 + inherit (stdenv.hostPlatform) isDarwin isLinux isAarch64; 30 + isAarch64Linux = isLinux && isAarch64; 31 + in 32 + assert lib.assertOneOf "GLPreference" GLPreference [ 33 + "GLVND" 34 + "LEGACY" 35 + ]; 36 + stdenv.mkDerivation (finalAttrs: { 37 + pname = "openmw"; 38 + version = "0.49.0"; 39 + 40 + __structuredAttrs = true; 41 + strictDeps = true; 42 + 43 + osg' = (openscenegraph.override { colladaSupport = true; }).overrideAttrs (oldAttrs: { 44 + patches = (oldAttrs.patches or [ ]) ++ [ 45 + (fetchpatch { 46 + # Darwin: Without this patch, OSG won't build osgdb_png.so, which is required by OpenMW. 47 + name = "darwin-osg-plugins-fix.patch"; 48 + url = "https://gitlab.com/OpenMW/openmw-dep/-/raw/1305497c009dc0e7a6a70fe14f0a2f92b96cbcb4/macos/osg.patch"; 49 + hash = "sha256-G8Y+fnR6FRGxECWrei/Ixch3A3PkRfH6b5q9iawsSCY="; 50 + }) 51 + ]; 52 + cmakeFlags = 53 + (oldAttrs.cmakeFlags or [ ]) 54 + ++ [ 55 + "-Wno-dev" 56 + (lib.cmakeFeature "OpenGL_GL_PREFERENCE" GLPreference) 57 + (lib.cmakeBool "BUILD_OSG_PLUGINS_BY_DEFAULT" false) 58 + (lib.cmakeBool "BUILD_OSG_DEPRECATED_SERIALIZERS" false) 59 + ] 60 + ++ (map (plugin: lib.cmakeBool "BUILD_OSG_PLUGIN_${plugin}" true) [ 61 + "BMP" 62 + "DAE" 63 + "DDS" 64 + "FREETYPE" 65 + "JPEG" 66 + "OSG" 67 + "PNG" 68 + "TGA" 69 + ]); 70 + }); 71 + 72 + bullet' = bullet.overrideAttrs (oldAttrs: { 73 + cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [ 74 + "-Wno-dev" 75 + (lib.cmakeFeature "OpenGL_GL_PREFERENCE" GLPreference) 76 + (lib.cmakeBool "USE_DOUBLE_PRECISION" true) 77 + (lib.cmakeBool "BULLET2_MULTITHREADING" true) 78 + ]; 79 + }); 80 + 81 + src = fetchFromGitLab { 82 + owner = "OpenMW"; 83 + repo = "openmw"; 84 + tag = "openmw-${finalAttrs.version}"; 85 + hash = "sha256-Eyjn3jPpo0d7XENg0Ea/3MN60lZBSUAMkz1UtTiIP80="; 86 + }; 87 + 88 + postPatch = '' 89 + sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12 90 + '' 91 + # Don't fix Darwin app bundle 92 + + lib.optionalString isDarwin '' 93 + sed -i '/fixup_bundle/d' CMakeLists.txt 94 + ''; 95 + 96 + nativeBuildInputs = [ 97 + cmake 98 + pkg-config 99 + ] 100 + ++ (with qt6Packages; [ 101 + wrapQtAppsHook 102 + ]); 103 + 104 + # If not set, OSG plugin .so files become shell scripts on Darwin. 105 + dontWrapQtApps = isDarwin; 106 + 107 + buildInputs = [ 108 + SDL2 109 + boost 110 + collada-dom 111 + ffmpeg 112 + libXt 113 + (if isAarch64Linux then lua else luajit) 114 + lz4 115 + mygui 116 + openal 117 + recastnavigation 118 + unshield 119 + yaml-cpp 120 + ] 121 + ++ (with qt6Packages; [ 122 + qttools 123 + ]) 124 + ++ (with finalAttrs; [ 125 + bullet' 126 + osg' 127 + ]); 128 + 129 + cmakeFlags = [ 130 + (lib.cmakeFeature "OpenGL_GL_PREFERENCE" GLPreference) 131 + (lib.cmakeBool "USE_LUAJIT" (!isAarch64Linux)) 132 + (lib.cmakeBool "OPENMW_USE_SYSTEM_RECASTNAVIGATION" true) 133 + (lib.cmakeBool "OPENMW_OSX_DEPLOYMENT" isDarwin) 134 + ]; 135 + 136 + meta = { 137 + description = "Unofficial open source engine reimplementation of the game Morrowind"; 138 + changelog = "https://gitlab.com/OpenMW/openmw/-/blob/${finalAttrs.src.tag}/CHANGELOG.md"; 139 + homepage = "https://openmw.org"; 140 + license = lib.licenses.gpl3Plus; 141 + maintainers = with lib.maintainers; [ 142 + marius851000 143 + sigmasquadron 144 + ]; 145 + platforms = with lib.platforms; linux ++ darwin ++ windows; 146 + # Nixpkgs' NT infrastructure is currently incapable of building this. 147 + badPlatforms = lib.platforms.windows; 148 + }; 149 + })
-130
pkgs/games/openmw/default.nix
··· 1 - { 2 - lib, 3 - stdenv, 4 - fetchFromGitLab, 5 - fetchpatch, 6 - 7 - SDL2, 8 - boost, 9 - bullet, 10 - cmake, 11 - ffmpeg, 12 - libXt, 13 - luajit, 14 - lz4, 15 - mygui, 16 - openal, 17 - openscenegraph, 18 - pkg-config, 19 - qttools, 20 - recastnavigation, 21 - unshield, 22 - wrapQtAppsHook, 23 - yaml-cpp, 24 - }: 25 - 26 - let 27 - GL = "GLVND"; # or "LEGACY"; 28 - 29 - osg' = (openscenegraph.override { colladaSupport = true; }).overrideDerivation (old: { 30 - patches = [ 31 - (fetchpatch { 32 - # Darwin: Without this patch, OSG won't build osgdb_png.so, which is required by OpenMW. 33 - name = "darwin-osg-plugins-fix.patch"; 34 - url = "https://gitlab.com/OpenMW/openmw-dep/-/raw/1305497c009dc0e7a6a70fe14f0a2f92b96cbcb4/macos/osg.patch"; 35 - sha256 = "sha256-G8Y+fnR6FRGxECWrei/Ixch3A3PkRfH6b5q9iawsSCY="; 36 - }) 37 - ]; 38 - cmakeFlags = 39 - (old.cmakeFlags or [ ]) 40 - ++ [ 41 - "-Wno-dev" 42 - "-DOpenGL_GL_PREFERENCE=${GL}" 43 - "-DBUILD_OSG_PLUGINS_BY_DEFAULT=0" 44 - "-DBUILD_OSG_DEPRECATED_SERIALIZERS=0" 45 - ] 46 - ++ (map (e: "-DBUILD_OSG_PLUGIN_${e}=1") [ 47 - "BMP" 48 - "DAE" 49 - "DDS" 50 - "FREETYPE" 51 - "JPEG" 52 - "OSG" 53 - "PNG" 54 - "TGA" 55 - ]); 56 - }); 57 - 58 - bullet' = bullet.overrideDerivation (old: { 59 - cmakeFlags = (old.cmakeFlags or [ ]) ++ [ 60 - "-Wno-dev" 61 - "-DOpenGL_GL_PREFERENCE=${GL}" 62 - "-DUSE_DOUBLE_PRECISION=ON" 63 - "-DBULLET2_MULTITHREADING=ON" 64 - ]; 65 - }); 66 - 67 - in 68 - stdenv.mkDerivation rec { 69 - pname = "openmw"; 70 - version = "0.49.0"; 71 - 72 - src = fetchFromGitLab { 73 - owner = "OpenMW"; 74 - repo = "openmw"; 75 - rev = "${pname}-${version}"; 76 - hash = "sha256-Eyjn3jPpo0d7XENg0Ea/3MN60lZBSUAMkz1UtTiIP80="; 77 - }; 78 - 79 - postPatch = '' 80 - sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12 81 - '' 82 - + lib.optionalString stdenv.hostPlatform.isDarwin '' 83 - # Don't fix Darwin app bundle 84 - sed -i '/fixup_bundle/d' CMakeLists.txt 85 - ''; 86 - 87 - nativeBuildInputs = [ 88 - cmake 89 - pkg-config 90 - wrapQtAppsHook 91 - ]; 92 - 93 - # If not set, OSG plugin .so files become shell scripts on Darwin. 94 - dontWrapQtApps = stdenv.hostPlatform.isDarwin; 95 - 96 - buildInputs = [ 97 - SDL2 98 - boost 99 - bullet' 100 - ffmpeg 101 - libXt 102 - luajit 103 - lz4 104 - mygui 105 - openal 106 - osg' 107 - qttools 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 - marius851000 127 - ]; 128 - platforms = platforms.linux ++ platforms.darwin; 129 - }; 130 - }
pkgs/games/openmw/tes3mp-gcc14-fix.patch pkgs/games/tes3mp/tes3mp-gcc14-fix.patch
pkgs/games/openmw/tes3mp.nix pkgs/games/tes3mp/default.nix
pkgs/games/openmw/tes3mp.patch pkgs/games/tes3mp/tes3mp.patch
+1 -3
pkgs/top-level/all-packages.nix
··· 14124 14124 14125 14125 openloco = pkgsi686Linux.callPackage ../games/openloco { }; 14126 14126 14127 - openmw = libsForQt5.callPackage ../games/openmw { }; 14128 - 14129 - openmw-tes3mp = libsForQt5.callPackage ../games/openmw/tes3mp.nix { }; 14127 + openmw-tes3mp = libsForQt5.callPackage ../games/tes3mp { }; 14130 14128 14131 14129 openraPackages_2019 = import ../games/openra_2019 { 14132 14130 inherit lib;