blob: 72b698ceb73015a3bdefc509d53f75f57a48c718 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
{ 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-2018-07-14";
src = fetchFromGitHub {
owner = "TES3MP";
repo = "CrabNet";
# usually fixed:
# https://github.com/GrimKriegor/TES3MP-deploy/blob/d2a4a5d3acb64b16d9b8ca85906780aeea8d311b/tes3mp-deploy.sh#L589
rev = "4eeeaad2f6c11aeb82070df35169694b4fb7b04b";
sha256 = "0p0li9l1i5lcliswm5w9jql0zff9i6fwhiq0bl130m4i7vpr4cr3";
};
nativeBuildInputs = [ cmake ];
installPhase = ''
install -Dm555 lib/libRakNetLibStatic.a $out/lib/libRakNetLibStatic.a
'';
};
coreScripts = stdenv.mkDerivation {
pname = "corescripts";
version = "unstable-2020-07-27";
src = fetchFromGitHub {
owner = "TES3MP";
repo = "CoreScripts";
# usually latest in stable branch (e.g. 0.7.1)
rev = "3c2d31595344db586d8585db0ef1fc0da89898a0";
sha256 = "sha256-m/pt2Et58HOMc1xqllGf4hjPLXNcc14+X0h84ouZDeg=";
};
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 = "openmw-tes3mp-unwrapped";
version = "unstable-2020-08-07";
src = fetchFromGitHub {
owner = "TES3MP";
repo = "openmw-tes3mp";
# usually latest in stable branch (e.g. 0.7.1)
rev = "ce5df6d18546e37aac9746d99c00d27a7f34b00d";
sha256 = "sha256-xLslShNA6rVFl9kt6BNGDpSYMpO25jBTCteLJoSTXdg=";
};
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"
];
# https://github.com/TES3MP/openmw-tes3mp/issues/552
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 \
--run "cd $out/bin"
makeWrapper ${unwrapped}/libexec/tes3mp-server $out/bin/tes3mp-server \
--run "mkdir -p $dir" \
--run "${crudini}/bin/crudini --merge $dir/${cfgFile.name} < ${cfgFile}" \
--run "cd $out/bin"
'';
}
|