add openmw-tes3mp

This commit is contained in:
Christian Ulrich 2023-02-10 18:45:17 +01:00
parent 5f8da17f07
commit 1eb06bec0e
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
3 changed files with 154 additions and 0 deletions

View File

@ -19,6 +19,8 @@ self: super:
nghttp3-debug = super.enableDebugging self.nghttp3;
openmw-tes3mp = super.callPackage ./pkgs/openmw/tes3mp.nix { };
picotls = super.callPackage ./pkgs/picotls/default.nix { };
picoquic = super.callPackage ./pkgs/picoquic/default.nix { };

139
pkgs/openmw/tes3mp.nix Normal file
View File

@ -0,0 +1,139 @@
{ lib
, stdenv
, cmake
, openmw
, fetchFromGitHub
, formats
, luajit
, makeWrapper
, symlinkJoin
, mygui
, crudini
}:
# revisions are taken from https://github.com/GrimKriegor/TES3MP-deploy
let
# raknet could also be split into dev and lib outputs
raknet = stdenv.mkDerivation {
pname = "raknet";
version = "unstable-2020-01-19";
src = fetchFromGitHub {
owner = "TES3MP";
repo = "CrabNet";
# usually fixed:
# https://github.com/GrimKriegor/TES3MP-deploy/blob/af49c67317258624debe1b5a9f8792f4cc3ad2d1/tes3mp-deploy.sh#L518
rev = "19e66190e83f53bcdcbcd6513238ed2e54878a21";
sha256 = "sha256-WIaJkSQnoOm9T7GoAwmWl7fNg79coIo/ILUsWcbH+lA=";
};
nativeBuildInputs = [ cmake ];
installPhase = ''
install -Dm555 lib/libRakNetLibStatic.a $out/lib/libRakNetLibStatic.a
'';
};
coreScripts = stdenv.mkDerivation {
pname = "corescripts";
version = "unstable-2022-10-21";
src = fetchFromGitHub {
owner = "TES3MP";
repo = "CoreScripts";
# usually latest in stable branch (e.g. 0.8.1)
rev = "6ae0a2a5d16171de3764817a7f8b1067ecde3def";
sha256 = "sha256-8j/Sr9IRMNFPEVfFzdb42PckHS3KW7FH7x7rRxIh5gY=";
};
buildCommand = ''
dir=$out/share/openmw-tes3mp
mkdir -p $dir
cp -r $src $dir/CoreScripts
'';
};
# build an unwrapped version so we don't have to rebuild it all over again in
# case the scripts or wrapper scripts change.
unwrapped = openmw.overrideAttrs (oldAttrs: rec {
pname = "tes3mp-unwrapped";
version = "0.8.1";
src = fetchFromGitHub {
owner = "TES3MP";
repo = "TES3MP";
# usually latest in stable branch (e.g. 0.8.1)
rev = "68954091c54d0596037c4fb54d2812313b7582a1";
sha256 = "sha256-8/bV4sw7Q8l8bDTHGQ0t4owf6J6h9q468JFx4KegY5o=";
};
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ makeWrapper ];
buildInputs = oldAttrs.buildInputs ++ [ luajit ];
cmakeFlags = oldAttrs.cmakeFlags ++ [
"-DBUILD_OPENCS=OFF"
"-DRakNet_INCLUDES=${raknet.src}/include"
"-DRakNet_LIBRARY_RELEASE=${raknet}/lib/libRakNetLibStatic.a"
"-DRakNet_LIBRARY_DEBUG=${raknet}/lib/libRakNetLibStatic.a"
];
prePatch = ''
substituteInPlace components/process/processinvoker.cpp \
--replace "\"./\"" "\"$out/bin/\""
'';
# https://github.com/TES3MP/openmw-tes3mp/issues/552
patches = oldAttrs.patches ++ [ ./tes3mp.patch ];
NIX_CFLAGS_COMPILE = "-fpermissive";
preConfigure = ''
substituteInPlace files/version.in \
--subst-var-by OPENMW_VERSION_COMMITHASH ${src.rev}
'';
# move everything that we wrap out of the way
postInstall = ''
mkdir -p $out/libexec
mv $out/bin/tes3mp-* $out/libexec
'';
meta = with lib; {
description = "Multiplayer for TES3:Morrowind based on OpenMW";
homepage = "https://tes3mp.com/";
license = licenses.gpl3Only;
maintainers = with maintainers; [ peterhoeg ];
platforms = [ "x86_64-linux" "i686-linux" ];
};
});
cfgFile = (formats.ini { }).generate "tes3mp-server.cfg" {
Plugins.home = "${coreScripts}/share/openmw-tes3mp/CoreScripts";
};
in
symlinkJoin rec {
name = "openmw-tes3mp-${unwrapped.version}";
inherit (unwrapped) version meta;
nativeBuildInputs = [ makeWrapper ];
paths = [ unwrapped ];
# crudini --merge will create the file if it doesn't exist
postBuild = ''
mkdir -p $out/bin
dir=\''${XDG_CONFIG_HOME:-\$HOME/.config}/openmw
makeWrapper ${unwrapped}/libexec/tes3mp-browser $out/bin/tes3mp-browser \
--chdir "$out/bin"
makeWrapper ${unwrapped}/libexec/tes3mp-server $out/bin/tes3mp-server \
--run "mkdir -p $dir" \
--run "${crudini}/bin/crudini --merge $dir/${cfgFile.name} < ${cfgFile}" \
--chdir "$out/bin"
'';
}

13
pkgs/openmw/tes3mp.patch Normal file
View File

@ -0,0 +1,13 @@
diff --git a/apps/openmw-mp/Script/Types.hpp b/apps/openmw-mp/Script/Types.hpp
index be365cfb8..204dcdc7b 100644
--- a/apps/openmw-mp/Script/Types.hpp
+++ b/apps/openmw-mp/Script/Types.hpp
@@ -105,7 +105,7 @@ struct ScriptFunctionPointer : public ScriptIdentity
void *addr;
#if (!defined(__clang__) && defined(__GNUC__))
template<typename R, typename... Types>
- constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr((void*)(addr)) {}
+ constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr(addr) {}
#else
template<typename R, typename... Types>
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr(addr) {}