2023-03-12 20:09:49 +00:00
{ lib , buildDotnetModule , dotnetCorePackages
2023-03-19 13:13:13 +00:00
, fetchFromGitHub
2023-03-12 20:09:49 +00:00
, SDL2 , freetype , openal , lua51Packages
} :
engine :
buildDotnetModule rec {
2023-03-19 13:13:13 +00:00
pname = " o p e n r a - ${ engine . build } " ;
inherit ( engine ) version ;
src = if engine ? src then engine . src else fetchFromGitHub {
owner = " O p e n R A " ;
repo = " O p e n R A " ;
rev = " ${ engine . build } - ${ engine . version } " ;
sha256 = engine . sha256 ;
} ;
2023-03-12 20:09:49 +00:00
nugetDeps = engine . deps ;
dotnet-sdk = dotnetCorePackages . sdk_6_0 ;
dotnet-runtime = dotnetCorePackages . runtime_6_0 ;
useAppHost = false ;
dotnetFlags = [ " - p : V e r s i o n = 0 . 0 . 0 . 0 " ] ; # otherwise dotnet build complains, version is saved in VERSION file anyway
dotnetBuildFlags = [ " - p : T a r g e t P l a f o r m = u n i x - g e n e r i c " ] ;
dotnetInstallFlags = [
" - p : T a r g e t P l a f o r m = u n i x - g e n e r i c "
" - p : C o p y G e n e r i c L a u n c h e r = T r u e "
" - p : C o p y C n c D l l = T r u e "
" - p : C o p y D 2 k D l l = T r u e "
" - p : U s e A p p H o s t = F a l s e "
] ;
dontDotnetFixup = true ;
2024-10-12 11:59:12 +01:00
# 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]
enableParallelBuilding = false ;
2023-03-12 20:09:49 +00:00
preBuild = ''
2023-10-21 14:20:35 +01:00
make VERSION = $ { engine . build } - $ { version } version
2023-03-12 20:09:49 +00:00
'' ;
postInstall = ''
# Create the file so that the install_data script will not attempt to download it.
# TODO: fetch the file and include it
touch ' ./IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP '
# Install all the asset data
2023-03-19 13:13:13 +00:00
(
. ./packaging/functions.sh
install_data . " $ o u t / l i b / ${ pname } " cnc d2k ra
)
2023-03-12 20:09:49 +00:00
# Replace precompiled libraries with links to native one.
# This is similar to configure-system-libraries.sh in the source repository
ln - s - f $ { lua51Packages . lua } /lib/liblua.so $ out/lib / $ { pname } /lua51.so
ln - s - f $ { SDL2 } /lib/libSDL2.so $ out/lib / $ { pname } /SDL2.so
ln - s - f $ { openal } /lib/libopenal.so $ out/lib / $ { pname } /soft_oal.so
ln - s - f $ { freetype } /lib/libfreetype.so $ out/lib / $ { pname } /freetype6.so
'' ;
postFixup = ''
2023-03-19 13:13:13 +00:00
(
. ./packaging/functions.sh
install_linux_shortcuts . " " " $ o u t / l i b / ${ pname } " " $ o u t / . b i n - u n w r a p p e d " " $ o u t / s h a r e " " ${ version } " cnc d2k ra
)
2023-03-12 20:09:49 +00:00
# Create Nix wrappers to the application scripts which setup the needed environment
for bin in $ ( find $ out/.bin-unwrapped - type f ) ; do
makeWrapper " $ b i n " " $ o u t / b i n / $ ( b a s e n a m e " $ bin " ) " \
2023-03-19 13:13:13 +00:00
- - prefix " P A T H " : " ${ lib . makeBinPath [ dotnet-runtime ] } "
2023-03-12 20:09:49 +00:00
done
'' ;
meta = with lib ; {
2024-01-12 16:07:33 +00:00
description = " O p e n S o u r c e r e a l - t i m e s t r a t e g y g a m e e n g i n e f o r e a r l y W e s t w o o d g a m e s s u c h a s C o m m a n d & C o n q u e r : R e d A l e r t . ${ engine . build } v e r s i o n " ;
2023-03-12 20:09:49 +00:00
homepage = " h t t p s : / / w w w . o p e n r a . n e t / " ;
license = licenses . gpl3 ;
maintainers = with maintainers ; [ mdarocha ] ;
platforms = [ " x 8 6 _ 6 4 - l i n u x " ] ;
mainProgram = " o p e n r a - r a " ;
} ;
}