summary refs log tree commit diff
path: root/pkgs/games/openra/default.nix
blob: de29118a68d675238cca253665d1f90b6041f9ba (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
{ stdenv, fetchurl, mono, makeWrapper, lua
, SDL2, freetype, openal, systemd, pkgconfig,
  dotnetPackages, gnome3
}:

let
  version = "20160508";
in stdenv.mkDerivation rec {
  name = "openra-${version}";

  meta = with stdenv.lib; {
    description = "Real Time Strategy game engine recreates the C&C titles";
    homepage    = "http://www.open-ra.org/";
    maintainers = [ maintainers.rardiol ];
    license     = licenses.gpl3;
    platforms   = platforms.linux;
  };

  src = fetchurl {
    name = "${name}.tar.gz";
    url = "https://github.com/OpenRA/OpenRA/archive/release-${version}.tar.gz";
    sha256 = "1vr5bvdkh0n5569ga2h7ggj43vnzr37hfqkfnsis1sg4vgwrnzr7";
  };

  dontStrip = true;

  buildInputs = with dotnetPackages;
     [ NUnit3 NewtonsoftJson MonoNat FuzzyLogicLibrary SmartIrc4net SharpZipLib MaxMindGeoIP2 MaxMindDb SharpFont StyleCopMSBuild StyleCopPlusMSBuild RestSharp NUnitConsole ]
     ++ [ lua gnome3.zenity ];
  nativeBuildInputs = [ mono makeWrapper lua pkgconfig ];

  patchPhase = ''
    sed -i 's/^VERSION.*/VERSION = release-${version}/g' Makefile
    substituteInPlace thirdparty/configure-native-deps.sh --replace "locations=\"" "locations=\"${lua}/lib "
    substituteInPlace Makefile --replace "@./thirdparty/fetch-geoip-db.sh" ""
  '';

  preConfigure = ''
    makeFlags="prefix=$out"
    make version
  '';

  preBuild = let dotnetPackagesDlls = with dotnetPackages; [
    "${MonoNat}/lib/dotnet/Mono.Nat/net40/Mono.Nat.dll"
    "${FuzzyLogicLibrary}/lib/dotnet/FuzzyLogicLibrary/Release/FuzzyLogicLibrary.dll"
    "${SmartIrc4net}/lib/dotnet/SmartIrc4net/net40/SmarIrc4net*"
    "${SharpZipLib}/lib/dotnet/SharpZipLib/20/ICSharpCode.SharpZipLib.dll"
    "${MaxMindGeoIP2}/lib/dotnet/MaxMind.GeoIP2/net40/MaxMind.GeoIP2*"
    "${MaxMindDb}/lib/dotnet/MaxMind.Db/net40/MaxMind.Db.*"
    "${SharpFont}/lib/dotnet/SharpFont/net20/SharpFont.dll"
    "${SharpFont}/lib/dotnet/SharpFont/SharpFont.dll.config"
    "${StyleCopMSBuild}/lib/dotnet/StyleCop.MSBuild/StyleCop*.dll"
    "${StyleCopPlusMSBuild}/lib/dotnet/StyleCopPlus.MSBuild/StyleCopPlus.dll"
    "${RestSharp}/lib/dotnet/RestSharp/net4-client/RestSharp.dll"
    "${NUnit}/lib/dotnet/NUnit/nunit.framework.*"
    "${NUnitConsole}/lib/dotnet/NUnit.Console/*"
    "${NewtonsoftJson}/lib/dotnet/Newtonsoft.Json/Newtonsoft.Json.dll"
    ];
    movePackages = [
      ( let filename = "Eluant.dll"; in { origin = fetchurl {
          url = "https://github.com/OpenRA/Eluant/releases/download/20160124/${filename}";
          sha256 = "1c20whz7dzfhg3szd62rvb79745x5iwrd5pp62j3bbj1q9wpddmb";
        }; target = filename; })

      ( let filename = "SDL2-CS.dll"; in { origin = fetchurl {
          url = "https://github.com/OpenRA/SDL2-CS/releases/download/20151227/${filename}";
          sha256 = "0gqw2wg37cqhhlc2a9lfc4ndkyfi4m8bkv7ckxbawgydjlknq83n";
        }; target = filename; })

      ( let filename = "SDL2-CS.dll.config"; in { origin = fetchurl {
          url = "https://github.com/OpenRA/SDL2-CS/releases/download/20151227/${filename}";
          sha256 = "15709iscdg44wd33szw5y0fdxwvqfjw8v3xjq6a0mm46gr7mkw7g";
        }; target = filename; })

      ( let filename = "OpenAL-CS.dll"; in { origin = fetchurl {
          url = "https://github.com/OpenRA/OpenAL-CS/releases/download/20151227/${filename}";
          sha256 = "0lvyjkn7fqys97wym8rwlcp6ay2z059iabfvlcxhlrscjpyr2cyk";
        }; target = filename; })

      ( let filename = "OpenAL-CS.dll.config"; in { origin = fetchurl {
          url = "https://github.com/OpenRA/OpenAL-CS/releases/download/20151227/${filename}";
          sha256 = "0wcmk3dw26s93598ck5jism5609v0y233i0f1b76yilyfimg9sjq";
        }; target = filename; })

      ( let filename = "GeoLite2-Country.mmdb.gz"; in { origin = fetchurl {
          url = "http://geolite.maxmind.com/download/geoip/database/${filename}";
          sha256 = "0a82v0sj4zf5vigrn1pd6mnbqz6zl3rgk9nidqqzy836as2kxk9v";
        }; target = filename; })
    ];
  in ''
    mkdir thirdparty/download/

    ${stdenv.lib.concatMapStringsSep "\n" (from: "cp -r ${from} thirdparty/download") dotnetPackagesDlls}
    ${stdenv.lib.concatMapStringsSep "\n" ({origin, target}: "cp ${origin} thirdparty/download/${target}") movePackages}

    make dependencies
  '';

  #todo: man-page
  buildFlags = [ "DEBUG=false" "default" ];

  installTargets = [ "install" "install-linux-icons" "install-linux-desktop" "install-linux-appdata" "install-linux-mime" ];

  postInstall = with stdenv.lib; let
    runtime = makeLibraryPath [ SDL2 freetype openal systemd lua ];
  in ''
    wrapProgram $out/lib/openra/launch-game.sh \
      --prefix PATH : "${mono}/bin" \
      --set PWD $out/lib/openra/ \
      --prefix LD_LIBRARY_PATH : "${runtime}"

    mkdir -p $out/bin
    echo -e "#!${stdenv.shell}\ncd $out/lib/openra && $out/lib/openra/launch-game.sh" > $out/bin/openra
    chmod +x $out/bin/openra
  '';
}