# Does not touch paths inside xplanePathStr. # Setup needed to integrate the addons. # HeadShake # Create the following softlink: # ln -sf /xplane-extra/HeadShake $xplanePathStr/Resources/plugins # Beautiful Roads: # Rename the following directory in "$xplanePathStr/Resources/default scenery/1000 roads": # mv textures textures.orig # # and create the following softlink to textures: # ln -sf /xplane-extra/beautiful-roads textures # # To switch to the old roads, callPackage this file with the beautifulRoads # attribute set to null. { stdenv, writeScript, buildFHSUserEnv , xplanePathStr , addons ? []}: let inherit (stdenv.lib) concatMapStrings optionalString unique; runScript = writeScript "x-plane-script" '' #!${stdenv.shell} sys=${stdenv.targetPlatform.system} sys=''${sys%-linux} bin=$1 : ''${XPLANEPATH:=${xplanePathStr}} export XPLANEPATH case "$bin" in X-Plane) exec "''${XPLANEPATH}/X-Plane-$sys" ;; Airfoil*) exec "''${XPLANEPATH}/Airfoil Maker-$sys" ;; Plane*) exec "''${XPLANEPATH}/Plane Maker-$sys" ;; Installer*) exec "''${XPLANEPATH}/X-Plane 11 Installer Linux" ;; ''') exec "''${XPLANEPATH}/X-Plane-$sys" ;; SHELL) exec "bash" ;; prepare) exec ${prepareScript} ;; revert) shift; exec ${revertScript} "$@" ;; /*) exec "$@" ;; *) shift; exec "''${XPLANEPATH}/$bin" "$@" ;; esac ''; uniqueAddons = unique addons; prepareScript = writeScript "x-plane-addons-prepare" ('' #!${stdenv.shell} set -e : ''${XPLANEPATH:=${xplanePathStr}} printf "Preparing %s for accessing addons\n" "$XPLANEPATH" >&2 mkdir -p "$XPLANEPATH/.addons" if [ -f "$XPLANEPATH/.addons/dont-prepare" ]; then printf "Warning: %s found. Not preparing tree.\n" "$XPLANEPATH/.addons/dont-prepare" >&2 exit 1 fi '' + (concatMapStrings (addon: optionalString (addon.passthru ? prepare) ('' # Addon ${addon.pname}-${addon.version} ADDONPATH=${addon} printf "Preparing %s\n" "${addon.pname}-${addon.version}" >&2 if [ -f "$XPLANEPATH/.addons/revert-${addon.pname}" ]; then printf "Warning: Old revert script found. Not modifying X-Plane tree. Revert first.\n" >&2 else ${addon.passthru.prepare} '' + (if (addon.passthru ? revert) then '' cat <<'EOF' >"$XPLANEPATH/.addons/revert-${addon.pname}" #!${stdenv.shell} set -e ${addon.passthru.revert} rm $0 EOF chmod +x "$XPLANEPATH/.addons/revert-${addon.pname}" fi '' else '' fi ''))) uniqueAddons)); revertScript = writeScript "x-plane-addons-revert" '' #!/bin/sh set -e : ''${XPLANEPATH:=${xplanePathStr}} printf "Reverting modifications made to %s\n" "$XPLANEPATH"; if [ $# -eq 0 ]; then printf "Reverting all modifications\n" for f in "$XPLANEPATH/.addons"/revert-* ; do printf "Reverting %s\n" "''${f##*/revert-}" "''${f}" done else for f in "$@" ; do printf "Reverting %s\n" "''${f##*/revert-}" "$XPLANEPATH"/.addons/revert-"''${f##*/revert-}" done fi ''; in buildFHSUserEnv rec { name = "x-plane-env"; passthru = { inherit addons; }; # Also add GAppsWrapper environment stuff such that binaries see the GTK theme... targetPkgs = pkgs: (with pkgs; [ unzip atk gdk_pixbuf cairo pango mesa_glu libGL openalSoft gtk2 glib dbus pulseaudio vulkan-tools vulkan-loader ] ++ (with xorg; [ libX11 libXext libXrandr libXcursor libXinerama ]) ++ # For reality expansion pack [ stdenv.cc.cc.lib curl openssl ] ++ # For fly with lua [ freeglut libudev ]); extraBuildCommands = '' chmod u+w $out/etc mkdir $out/etc/openal chmod u-w $out/etc echo "drivers=pulse" > $out/etc/openal/alsoft.conf mkdir $out/xplane-extra '' + (concatMapStrings (addon: optionalString (addon.passthru ? build) '' ADDONPATH=${addon} printf "Addon ${addon.pname}\n" >&2 ${addon.passthru.build} '') uniqueAddons); inherit runScript; }