@@ -0,0 +1,65 @@
1+{ stdenv
2+, lib
3+, fetchFromGitHub
4+, elkhound
5+, ocaml-ng
6+, perl
7+, which
8+}:
9+
10+let
11+ # 1. Needs ocaml >= 4.04 and <= 4.11
12+ # 2. ocaml 4.10 defaults to safe (immutable) strings so we need a version with
13+ # that disabled as weidu is strongly dependent on mutable strings
14+ ocaml' = ocaml-ng.ocamlPackages_4_10.ocaml.overrideAttrs (old: {
15+ configureFlags = old.configureFlags ++ [
16+ # https://github.com/WeiDUorg/weidu/issues/197
17+ "--disable-force-safe-string"
18+ ];
19+ });
20+
21+in
22+stdenv.mkDerivation rec {
23+ pname = "weidu";
24+ version = "247.00";
25+
26+ src = fetchFromGitHub {
27+ owner = "WeiDUorg";
28+ repo = pname;
29+ rev = "v${version}";
30+ sha256 = "sha256-vAIIYn0urQnnL82mdfwJtahrS3uWPFferm+0F13TKcw=";
31+ };
32+
33+ postPatch = ''
34+ substitute sample.Configuration Configuration \
35+ --replace /usr/bin ${lib.makeBinPath [ ocaml' ]} \
36+ --replace elkhound ${elkhound}/bin/elkhound
37+
38+ mkdir -p obj/{.depend,x86_LINUX}
39+ '';
40+
41+ nativeBuildInputs = [ elkhound ocaml' perl which ];
42+
43+ buildFlags = [ "weidu" "weinstall" "tolower" ];
44+
45+ installPhase = ''
46+ runHook preInstall
47+
48+ for b in tolower weidu weinstall; do
49+ install -Dm555 $b.asm.exe $out/bin/$b
50+ done
51+
52+ install -Dm444 -t $out/share/doc/weidu README* COPYING
53+
54+ runHook postInstall
55+ '';
56+
57+ meta = with lib; {
58+ description = "InfinityEngine Modding Engine";
59+ homepage = "https://weidu.org";
60+ license = licenses.gpl2Only;
61+ maintainers = with maintainers; [ peterhoeg ];
62+ # should work fine on both Darwin and Windows
63+ platforms = platforms.linux;
64+ };
65+}