1{
2 lib,
3 buildDotnetModule,
4 dotnetCorePackages,
5 fetchFromGitHub,
6 SDL2,
7 freetype,
8 openal,
9 lua51Packages,
10 openRaUpdater,
11}:
12engine:
13
14let
15 pname = "openra-${engine.build}";
16 version = engine.version;
17 dotnet-sdk = engine.dotnet-sdk;
18in
19buildDotnetModule {
20 inherit pname version dotnet-sdk;
21
22 src = fetchFromGitHub {
23 owner = "OpenRA";
24 repo = "OpenRA";
25 rev = if lib.hasAttr "rev" engine then engine.rev else "${engine.build}-${engine.version}";
26 inherit (engine) hash;
27 };
28
29 passthru = {
30 updateScript = {
31 command = openRaUpdater engine;
32 supportedFeatures = [ "commit" ];
33 };
34 };
35
36 nugetDeps = engine.deps;
37
38 useAppHost = false;
39
40 dotnetFlags = [ "-p:Version=0.0.0.0" ]; # otherwise dotnet build complains, version is saved in VERSION file anyway
41
42 dotnetBuildFlags = [ "-p:TargetPlaform=unix-generic" ];
43 dotnetInstallFlags = [
44 "-p:TargetPlaform=unix-generic"
45 "-p:CopyGenericLauncher=True"
46 "-p:CopyCncDll=True"
47 "-p:CopyD2kDll=True"
48 "-p:UseAppHost=False"
49 ];
50
51 dontDotnetFixup = true;
52
53 # Microsoft.NET.Publish.targets(248,5): error MSB3021: Unable to copy file "[...]/Newtonsoft.Json.dll" to "[...]/Newtonsoft.Json.dll". Access to the path '[...]Newtonsoft.Json.dll' is denied. [/build/source/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj]
54 enableParallelBuilding = false;
55
56 preBuild = ''
57 make VERSION=${engine.build}-${version} version
58 '';
59
60 postInstall = ''
61 # Create the file so that the install_data script will not attempt to download it.
62 # TODO: fetch the file and include it
63 touch './IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP'
64
65 # Install all the asset data
66 (
67 . ./packaging/functions.sh
68 install_data . "$out/lib/${pname}" cnc d2k ra
69 )
70
71 # Replace precompiled libraries with links to native one.
72 # This is similar to configure-system-libraries.sh in the source repository
73 ln -s -f ${lua51Packages.lua}/lib/liblua.so $out/lib/${pname}/lua51.so
74 ln -s -f ${SDL2}/lib/libSDL2.so $out/lib/${pname}/SDL2.so
75 ln -s -f ${openal}/lib/libopenal.so $out/lib/${pname}/soft_oal.so
76 ln -s -f ${freetype}/lib/libfreetype.so $out/lib/${pname}/freetype6.so
77 '';
78
79 postFixup = ''
80 (
81 . ./packaging/functions.sh
82 install_linux_shortcuts . "" "$out/lib/${pname}" "$out/.bin-unwrapped" "$out/share" "${version}" cnc d2k ra
83 )
84
85 # Create Nix wrappers to the application scripts which setup the needed environment
86 for bin in $(find $out/.bin-unwrapped -type f); do
87 makeWrapper "$bin" "$out/bin/$(basename "$bin")" \
88 --prefix "PATH" : "${lib.makeBinPath [ dotnet-sdk.runtime ]}"
89 done
90 '';
91
92 meta = {
93 description = "Open Source real-time strategy game engine for early Westwood games such as Command & Conquer: Red Alert. ${engine.build} version";
94 homepage = "https://www.openra.net/";
95 license = lib.licenses.gpl3;
96 maintainers = [ lib.maintainers.mdarocha ];
97 platforms = [ "x86_64-linux" ];
98 mainProgram = "openra-ra";
99 };
100}