2021-05-20 23:08:51 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, cmake
|
|
|
|
, openmw
|
|
|
|
, fetchFromGitHub
|
2023-10-19 13:55:26 +00:00
|
|
|
, fetchpatch
|
2021-05-20 23:08:51 +00:00
|
|
|
, luajit
|
|
|
|
, makeWrapper
|
|
|
|
, symlinkJoin
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# revisions are taken from https://github.com/GrimKriegor/TES3MP-deploy
|
|
|
|
|
|
|
|
let
|
2021-05-20 23:08:51 +00:00
|
|
|
# raknet could also be split into dev and lib outputs
|
2024-02-29 20:09:43 +00:00
|
|
|
raknet = stdenv.mkDerivation {
|
2021-05-20 23:08:51 +00:00
|
|
|
pname = "raknet";
|
2023-03-15 16:39:30 +00:00
|
|
|
version = "unstable-2020-01-19";
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "TES3MP";
|
|
|
|
repo = "CrabNet";
|
|
|
|
# usually fixed:
|
|
|
|
# https://github.com/GrimKriegor/TES3MP-deploy/blob/d2a4a5d3acb64b16d9b8ca85906780aeea8d311b/tes3mp-deploy.sh#L589
|
2023-03-15 16:39:30 +00:00
|
|
|
rev = "19e66190e83f53bcdcbcd6513238ed2e54878a21";
|
|
|
|
sha256 = "WIaJkSQnoOm9T7GoAwmWl7fNg79coIo/ILUsWcbH+lA=";
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
patches = [
|
|
|
|
# gcc-13 build fix:
|
|
|
|
# https://github.com/TES3MP/CrabNet/pull/18
|
|
|
|
(fetchpatch {
|
|
|
|
name = "gcc-13.patch";
|
|
|
|
url = "https://github.com/TES3MP/CrabNet/commit/3ec9a338a7cefd5cc751c9d29095cafa4c73be20.patch";
|
|
|
|
hash = "sha256-zE87icjX9GSnApgKQXj0K4IjlrReV/upFLjVgNYkNfM=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DCRABNET_ENABLE_DLL=OFF"
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
2021-05-20 23:08:51 +00:00
|
|
|
install -Dm555 lib/libRakNetLibStatic.a $out/lib/libRakNetLibStatic.a
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2024-02-29 20:09:43 +00:00
|
|
|
};
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
coreScripts = stdenv.mkDerivation {
|
|
|
|
pname = "corescripts";
|
2023-03-15 16:39:30 +00:00
|
|
|
version = "0.8.1";
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "TES3MP";
|
|
|
|
repo = "CoreScripts";
|
|
|
|
# usually latest in stable branch (e.g. 0.7.1)
|
2023-03-15 16:39:30 +00:00
|
|
|
rev = "6ae0a2a5d16171de3764817a7f8b1067ecde3def";
|
|
|
|
sha256 = "8j/Sr9IRMNFPEVfFzdb42PckHS3KW7FH7x7rRxIh5gY=";
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
dir=$out/share/openmw-tes3mp
|
|
|
|
mkdir -p $dir
|
|
|
|
cp -r $src $dir/CoreScripts
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
# 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 = "openmw-tes3mp-unwrapped";
|
2023-03-15 16:39:30 +00:00
|
|
|
version = "0.8.1";
|
2020-06-15 15:56:04 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-05-20 23:08:51 +00:00
|
|
|
owner = "TES3MP";
|
2023-03-15 16:39:30 +00:00
|
|
|
repo = "TES3MP";
|
2021-05-20 23:08:51 +00:00
|
|
|
# usually latest in stable branch (e.g. 0.7.1)
|
2023-03-15 16:39:30 +00:00
|
|
|
rev = "68954091c54d0596037c4fb54d2812313b7582a1";
|
|
|
|
sha256 = "8/bV4sw7Q8l8bDTHGQ0t4owf6J6h9q468JFx4KegY5o=";
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ makeWrapper ];
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
buildInputs = oldAttrs.buildInputs ++ [ luajit ];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
prePatch = ''
|
|
|
|
substituteInPlace components/process/processinvoker.cpp \
|
|
|
|
--replace "\"./\"" "\"$out/bin/\""
|
|
|
|
'';
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
patches = [
|
2024-02-29 20:09:43 +00:00
|
|
|
# glibc-2.34 support
|
2023-10-19 13:55:26 +00:00
|
|
|
(fetchpatch {
|
|
|
|
url = "https://gitlab.com/OpenMW/openmw/-/commit/98a7d90ee258ceef9c70b0b2955d0458ec46f048.patch";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-RhbIGeE6GyqnipisiMTwWjcFnIiR055hUPL8IkjPgZw=";
|
|
|
|
})
|
|
|
|
|
|
|
|
# gcc-13 build fix:
|
|
|
|
# https://github.com/TES3MP/TES3MP/pull/674
|
|
|
|
(fetchpatch {
|
|
|
|
name = "gcc-13.patch";
|
|
|
|
url = "https://github.com/TES3MP/TES3MP/commit/7921f71a79e96f817a2009100e5105a7948b3fe2.patch";
|
|
|
|
hash = "sha256-mpxuOSPA2xixgBeYXsxutEUI7VJL5PxAeZgaNU7YkJQ=";
|
2023-10-19 13:55:26 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
# https://github.com/TES3MP/openmw-tes3mp/issues/552
|
|
|
|
./tes3mp.patch
|
|
|
|
];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-fpermissive";
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
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" ];
|
2020-06-15 15:56:04 +00:00
|
|
|
};
|
|
|
|
});
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
tes3mp-server-run = ''
|
|
|
|
config="''${XDG_CONFIG_HOME:-''$HOME/.config}"/openmw
|
|
|
|
data="''${XDG_DATA_HOME:-''$HOME/.local/share}"/openmw
|
|
|
|
if [[ ! -f "$config"/tes3mp-server.cfg && ! -d "$data"/server ]]; then
|
|
|
|
mkdir -p "$config"
|
|
|
|
echo [Plugins] > "$config"/tes3mp-server.cfg
|
|
|
|
echo "home = $data/server" >> "$config"/tes3mp-server.cfg
|
|
|
|
mkdir -p "$data"
|
|
|
|
cp -r ${coreScripts}/share/openmw-tes3mp/CoreScripts "$data"/server
|
|
|
|
chmod -R u+w "$data"/server
|
|
|
|
fi
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
in
|
2023-03-15 16:39:30 +00:00
|
|
|
symlinkJoin {
|
2021-05-20 23:08:51 +00:00
|
|
|
name = "openmw-tes3mp-${unwrapped.version}";
|
|
|
|
inherit (unwrapped) version meta;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
paths = [ unwrapped ];
|
2021-02-19 19:06:45 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
postBuild = ''
|
|
|
|
mkdir -p $out/bin
|
2020-05-29 06:06:01 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
makeWrapper ${unwrapped}/libexec/tes3mp-browser $out/bin/tes3mp-browser \
|
2022-04-27 09:35:20 +00:00
|
|
|
--chdir "$out/bin"
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
makeWrapper ${unwrapped}/libexec/tes3mp-server $out/bin/tes3mp-server \
|
2023-03-15 16:39:30 +00:00
|
|
|
--run '${tes3mp-server-run}' \
|
2022-04-27 09:35:20 +00:00
|
|
|
--chdir "$out/bin"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-05-20 23:08:51 +00:00
|
|
|
}
|