# note: there is a generic builder in pkgs/games/sm64ex/generic.nix that is meant to help build sm64ex and its forks; however sm64coopdx has departed significantly enough in its build that it doesn't make sense to use that other than the baseRom derivation
# the baserom is needed both at build time and run time
ln-s${baserom}baserom.us.z64
# remove -march flags, stdenv manages them
substituteInPlaceMakefile\
--replace-fail'-march=$(TARGET_ARCH)'""
'';
installPhase=''
runHookpreInstall
localbuilt=$PWD/build/us_pc
localshare=$out/share/sm64coopdx
mkdir-p$share
cp$built/sm64coopdx$share/sm64coopdx
cp-r$built/{dynos,lang,mods,palettes}$share
# the baserom is needed both at build time and run time
ln-s${baserom}$share/baserom.us.z64
${lib.optionalStringenableDiscord''
cp$built/libdiscord_game_sdk*$share
''}
# coopdx always tries to load resources from the binary's directory, with no obvious way to change. Thus this small wrapper script to always run from the /share directory that has all the resources