{ stdenv , lib , mkXPlaneAddon }: mkXPlaneAddon { pname = "x-world-vegetation"; version = "1.0"; fname = "simHeaven_X-World_Vegetation_Library.7z"; sha256 = "sha256-NxiLAmnz2YHrc/MyGfExEzCdl/yvURNSWMGcIQ8Csnw="; forumlink = "https://simheaven.com/simdownloads/x-world-vegetation-library/"; buildCommand = '' mkdir -p "$out/Custom Scenery/" 7z x $src cp -r simHeaven* "$out/Custom Scenery" ''; passthru = let dirName="simHeaven_X-World_Vegetation_Library"; addonPath = "$XPLANEPATH/Custom Scenery/${dirName}"; in { build = '' ln -s $ADDONPATH $out/xplane-extra/x-world-vegetation ''; prepare = '' mkdir -p "${addonPath}" for f in "/xplane-extra/x-world-vegetation/Custom Scenery/${dirName}/"* ; do ln -s "$f" "${addonPath}/$(basename "$f")" done ln -s "$XPLANEPATH/Resources/default scenery/1200 forests" "${addonPath}/1200 forests" ( cd "$XPLANEPATH" if grep -q -E 'Custom Scenery/yOrtho4XP_Overlays' 'Custom Scenery/scenery_packs.ini' ; then sed -i -e '/^SCENERY_PACK Custom Scenery\/${dirName}\/$/d' 'Custom Scenery/scenery_packs.ini' sed -i -e "/^SCENERY_PACK Custom Scenery\/yOrtho4XP_Overlays/i\ SCENERY_PACK Custom Scenery\/${dirName}/" 'Custom Scenery/scenery_packs.ini' else sed -i -e '/^SCENERY_PACK Custom Scenery\/${dirName}\/$/d' 'Custom Scenery/scenery_packs.ini' sed -i -e '$a\ SCENERY_PACK Custom Scenery\/${dirName}/' 'Custom Scenery/scenery_packs.ini' fi ) ''; revert = '' if [ -d "${addonPath}" ]; then rm -r "${addonPath}" else false fi ''; }; }