diff --git a/default.nix b/default.nix index 992f758..ef475dd 100644 --- a/default.nix +++ b/default.nix @@ -6,6 +6,22 @@ let flip = super.stdenv.lib.flip; callPackage = super.lib.callPackageWith self; _self = { + xPlaneEnv = callPackage ./x-plane { xplanePathStr = "/home/games/xplane"; + addons = [ headshake beautifulRoads samBasic samGlobalTrees flyWithLua vividSky airportEnvHD betterLights extendedNightLights ]; }; + xPlaneSDK = callPackage ./x-plane/sdk.nix {}; + + airportEnvHD = callPackage ./x-plane/airport-env-hd.nix {}; + beautifulRoads = callPackage ./x-plane/beautiful-roads.nix {}; + betterLights = callPackage ./x-plane/better-lights.nix {}; + extendedNightLights = callPackage ./x-plane/enl {}; + flyWithLua = callPackage ./x-plane/fly-with-lua.nix {}; + headshake = callPackage ./x-plane/headshake {}; + mkXPlaneAddon = callPackage ./x-plane/addon.nix {}; + samSuite = callPackage ./x-plane/sam-suite {}; + samBasic = callPackage ./x-plane/sam-suite/sam-basic.nix {}; + samGlobalTrees = callPackage ./x-plane/sam-suite/global-trees.nix {}; + vividSky = callPackage ./x-plane/vivid-sky.nix {}; + # flightgear = libsForQt5.callPackage ./flightgear { }; # openscenegraph = callPackage ./openscenegraph.nix { inherit (xorg) libX11 libXrandr; }; # simgear = callPackage ./simgear.nix { inherit (xorg) libX11 libXext libXi libICE diff --git a/x-plane/addon.nix b/x-plane/addon.nix new file mode 100644 index 0000000..4933609 --- /dev/null +++ b/x-plane/addon.nix @@ -0,0 +1,26 @@ +{ stdenv, requireFile, unzip, p7zip }: +{ pname +, version +, fname +, sha256 +, forumlink +, passthru ? {} +, ... }@args: + +let + pruned = builtins.removeAttrs args [ "pname" "version" "fname" "sha256" "forumlink" "passthru" ]; + +in stdenv.mkDerivation ({ + src = requireFile { + message = '' + Download the Addon from: + ${forumlink} + + Then add it to your nix store, e.g., by using + "nix-prefetch-url file://\$PWD/${fname}" from the directory where you saved it. + ''; + name = fname; + inherit sha256; + }; + nativeBuildInputs = [ p7zip unzip ]; +} // args) diff --git a/x-plane/airport-env-hd.nix b/x-plane/airport-env-hd.nix new file mode 100644 index 0000000..82b58f6 --- /dev/null +++ b/x-plane/airport-env-hd.nix @@ -0,0 +1,45 @@ +{ stdenv, mkXPlaneAddon +, europeanNumbers ? false }: + +mkXPlaneAddon { + pname = "airport-env-hd"; + version = "2.13"; + + fname = "Airport_Environment_HD_2.13.zip"; + sha256 = "1m4wdr2ld0brynaf422hjvqcyq4bryanni12bg96j0m02szpmvs6"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/35172-airport-environment-hd/"; + buildCommand = '' + mkdir -p $out/Resources/bitmaps/runways $out/"Custom Scenery" + unzip $src + cp -r "Part 1 "*/* $out/Resources/bitmaps/runways + cp -r "Part 2"*/* "$out/Custom Scenery" + '' + (stdenv.lib.optionalString europeanNumbers '' + cp -r "Part 1.5"*/* $out/Resources/bitmaps/runways + ''); + + passthru = { + build = '' + ln -s $ADDONPATH $out/xplane-extra/AirportEnvHD + ''; + prepare = '' + for f in asphalt concrete goodgrass rway_blaspad.dds rway_shoulders.dds skids.png taxi.dds taxi_LIT.dds; do + mv "$XPLANEPATH/Resources/bitmaps/runways/$f" "$XPLANEPATH/Resources/bitmaps/runways/''${f}.orig" + ln -s /xplane-extra/AirportEnvHD/Resources/bitmaps/runways/$f "$XPLANEPATH/Resources/bitmaps/runways" + done + ln -s "/xplane-extra/AirportEnvHD/Custom Scenery/Airport Environment HD" "$XPLANEPATH/Custom Scenery/Airport Environment HD" + ''; + revert = '' + if [ -L "$XPLANEPATH/Custom Scenery//Airport Environment HD" ]; then + rm "$XPLANEPATH/Custom Scenery//Airport Environment HD" + else + false + fi + for f in asphalt concrete goodgrass rway_blaspad.dds rway_shoulders.dds skids.png taxi.dds taxi_LIT.dds; do + if [ -e "$XPLANEPATH/Resources/bitmaps/runways/''${f}.orig" ]; then + rm "$XPLANEPATH/Resources/bitmaps/runways/''${f}" + mv "$XPLANEPATH/Resources/bitmaps/runways/''${f}.orig" "$XPLANEPATH/Resources/bitmaps/runways/$f" + fi + done + ''; + }; +} diff --git a/x-plane/beautiful-roads.nix b/x-plane/beautiful-roads.nix new file mode 100644 index 0000000..ae78bbe --- /dev/null +++ b/x-plane/beautiful-roads.nix @@ -0,0 +1,31 @@ +{ stdenv, mkXPlaneAddon }: + +mkXPlaneAddon { + pname = "beautiful-roads"; + version = "2"; + + fname = "ARIF-ROADS-RAILS.zip"; + sha256 = "152150k7avnjma53b8x7d790lqd2dk35913aw8z8bkgcz5jdi1y4"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/42414-beautiful-roads-and-rails-for-xp-113/"; + buildCommand = '' + unzip $src ARIF-ROADS-RAILS/textures/\* + mv ARIF-ROADS-RAILS/textures $out + ''; + passthru = { + build = '' + ln -s $ADDONPATH $out/xplane-extra/beautiful-roads + ''; + prepare = '' + mv "$XPLANEPATH/Resources/default scenery/1000 roads/textures" "$XPLANEPATH/Resources/default scenery/1000 roads/textures.orig" + ln -s /xplane-extra/beautiful-roads "$XPLANEPATH/Resources/default scenery/1000 roads/textures" + ''; + revert = '' + if [ -L "$XPLANEPATH/Resources/default scenery/1000 roads/textures" -a -d "$XPLANEPATH/Resources/default scenery/1000 roads/textures.orig" ]; then + rm "$XPLANEPATH/Resources/default scenery/1000 roads/textures" + mv "$XPLANEPATH/Resources/default scenery/1000 roads/textures.orig" "$XPLANEPATH/Resources/default scenery/1000 roads/textures" + else + false + fi + ''; + }; +} diff --git a/x-plane/better-lights.nix b/x-plane/better-lights.nix new file mode 100644 index 0000000..a7246c8 --- /dev/null +++ b/x-plane/better-lights.nix @@ -0,0 +1,31 @@ +{ stdenv, mkXPlaneAddon }: + +mkXPlaneAddon { + pname = "better-lights"; + version = "2"; + + fname = "lights.txt"; + sha256 = "1fh5b2rwsws1095nikq7nfs49slq2rw3wwg6w5ncgq2pf083jvm5"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/36455-better-lights-x-plane-11-v2/"; + buildCommand = '' + mkdir -p $out + cp $src $out/lights.txt + ''; + passthru = { + build = '' + ln -s $ADDONPATH $out/xplane-extra/better-lights + ''; + prepare = '' + mv "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt" "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt.orig" + ln -s /xplane-extra/better-lights/lights.txt "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt" + ''; + revert = '' + if [ -L "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt" ]; then + rm "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt" + mv "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt.orig" "$XPLANEPATH/Resources/bitmaps/world/lites/lights.txt" + else + false + fi + ''; + }; +} diff --git a/x-plane/default.nix b/x-plane/default.nix new file mode 100644 index 0000000..4a5b1c0 --- /dev/null +++ b/x-plane/default.nix @@ -0,0 +1,126 @@ +# 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" '' + #!${stdenv.shell} + 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 ] ++ + (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; +} diff --git a/x-plane/enl/default.nix b/x-plane/enl/default.nix new file mode 100644 index 0000000..7fb4e2e --- /dev/null +++ b/x-plane/enl/default.nix @@ -0,0 +1,59 @@ +{ stdenv, requireFile, unrar }: +let + sFile = { fname, forumlink, sha256 }: requireFile { + message = '' + Download the Addon from: + ${forumlink} + + Then add it to your nix store, e.g., by using + "nix-prefetch-url file://\$PWD/${fname}" from the directory where you saved it. + ''; + name = fname; + inherit sha256; + }; + +in stdenv.mkDerivation { + pname = "extended-night-lights"; + version = "1.0.0"; + + srcs = [ + (sFile { fname = "Oceania_Lights.rar"; + sha256 = "0s2xjym6naqiy3mqqxkjmlgx3gaaxlfa59hcchmvbv6frpfj1172"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/50516-extended-night-lighting-oceania-new-zealand-fiji-new-caledonia-papua-new-guinea/"; }) + (sFile { fname = "Asia.rar"; + sha256 = "0cs7f07pwx82vam73klkmbxfv71nb7a0n9macqln5nxmz6qd9vh5"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/50914-extended-night-lighting-asia/"; }) + ]; + + nativeBuildInputs = [ unrar ]; + buildCommand = '' + mkdir -p $out/"Custom Scenery" + for s in $srcs ; do + unrar x $s + done + cp -r */* $out/"Custom Scenery" + ''; + + passthru = { + build = '' + ln -s $ADDONPATH $out/xplane-extra/extended-night-lights + ''; + prepare = '' + : > "$XPLANEPATH/.addons/enl-files" + for f in /xplane-extra/extended-night-lights/"Custom Scenery"/* ; do + ln -s "$f" "$XPLANEPATH/''${f#/xplane-extra/extended-night-lights/}" + printf "%s\n" "''${f#/xplane-extra/extended-night-lights/}" >> "$XPLANEPATH/.addons/enl-files" + done + ''; + revert = '' + if [ -e "$XPLANEPATH/.addons/enl-files" ]; then + while read f ; do + rm "$XPLANEPATH/$f" + done < "$XPLANEPATH/.addons/enl-files" + rm "$XPLANEPATH/.addons/enl-files" + else + false + fi + ''; + }; +} diff --git a/x-plane/fly-with-lua.nix b/x-plane/fly-with-lua.nix new file mode 100644 index 0000000..80f7c18 --- /dev/null +++ b/x-plane/fly-with-lua.nix @@ -0,0 +1,42 @@ +{ mkXPlaneAddon }: + +mkXPlaneAddon rec { + pname = "fly-with-lua"; + version = "2.7.22"; + + fname = "FlyWithLua_NG_v${version}_Lin_Mac_Win.zip"; + sha256 = "1vd1f3vn035jxbg7cqzciba0ibl35kp8q4yirdqvffbzs2id206f"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/38445-flywithlua-ng-next-generation-edition-for-x-plane-11-win-lin-mac/"; + buildCommand = '' + mkdir -p $out + cd $out + unzip $src + ''; + + passthru = { + build = '' + ln -s $ADDONPATH/FlyWithLua $out/xplane-extra/FlyWithLua + ''; + prepare = '' + mkdir -p "$XPLANEPATH/Resources/plugins/FlyWithLua" "$XPLANEPATH/Resources/plugins/FlyWithLua/Scripts" + for f in fwl_prefs.ini 64 Internals Modules "Scripts (Quarantine)" "Scripts (disabled)"; do + cp -r --no-preserve=mode -t "$XPLANEPATH/Resources/plugins/FlyWithLua" /xplane-extra/FlyWithLua/"$f" + done + for f in user.ini user.exit; do + if [ ! -f "$XPLANEPATH/Resources/plugins/FlyWithLua/$f" ]; then + cp --no-preserve=mode -t "$XPLANEPATH/Resources/plugins/FlyWithLua" /xplane-extra/FlyWithLua/$f + fi + done + touch "$XPLANEPATH/Resources/plugins/FlyWithLua/.prepared" + ''; + revert = '' + if [ -f "$XPLANEPATH/Resources/plugins/FlyWithLua/.prepared" ]; then + for f in fwl_prefs.ini 64 Internals Modules "Scripts (disabled)" ; do + rm -r "$XPLANEPATH/Resources/plugins/FlyWithLua/$f" + done + else + false + fi + ''; + }; +} diff --git a/x-plane/headshake/default.nix b/x-plane/headshake/default.nix new file mode 100644 index 0000000..fd335e9 --- /dev/null +++ b/x-plane/headshake/default.nix @@ -0,0 +1,44 @@ +{ stdenv, cmake, fetchurl, fetchFromGitHub, unzip, xPlaneSDK }: +let +in stdenv.mkDerivation rec { + pname = "headshake"; + version = "1.12.10"; + src = fetchFromGitHub { + repo = pname; + rev = "v${version}"; + owner = "simcodersdotcom"; + sha256 = "139kwg28arfrb2z51hpv6dzjs45js5rpp3rrjskjalvd2rkn38zs"; + }; + + patches = [ ./src-path.diff ]; + + nativeBuildInputs = [ cmake ]; + cmakeFlags = [ "-DCMP_LIN=ON" "-DSDK_PATH=${xPlaneSDK}" ]; + installPhase = '' + mkdir -p $out + cp -r ../bin/Release/HeadShake/* $out + ''; + + passthru = { + # $out is the output path of the FHS environment + build = '' + ln -s $ADDONPATH $out/xplane-extra/HeadShake + ''; + prepare = '' + ln -s /xplane-extra/HeadShake "$XPLANEPATH/Resources/plugins/HeadShake" + ''; + revert = '' + if [ -L "$XPLANEPATH/Resources/plugins/HeadShake" ]; then + rm "$XPLANEPATH/Resources/plugins/HeadShake" + else + false + fi + ''; + }; + + meta = { + description = "Headshake plugin for X-Plane 11"; + license = stdenv.lib.licenses.gpl3; + maintainer = [ stdenv.lib.maintainers.spacefrogg ]; + }; +} diff --git a/x-plane/headshake/src-path.diff b/x-plane/headshake/src-path.diff new file mode 100644 index 0000000..b21a7eb --- /dev/null +++ b/x-plane/headshake/src-path.diff @@ -0,0 +1,13 @@ +diff -ru source.oric/CMakeLists.txt source/CMakeLists.txt +--- source.oric/CMakeLists.txt 2020-04-19 18:45:09.885152206 +0200 ++++ source/CMakeLists.txt 2020-04-19 20:12:20.327739132 +0200 +@@ -14,7 +14,8 @@ + option(CMP_MAC "CMP_MAC" OFF) + + # Set the libraries path: edit this line to specify your custom library path +-get_filename_component(SDK_PATH "../SDK/" ABSOLUTE) ++option(SDK_PATH "SDK_PATH" "../SDK/") ++get_filename_component(SDK_PATH "${SDK_PATH}" ABSOLUTE) + message("-- Detecting X-Plane SDK path") + if(NOT EXISTS ${SDK_PATH}) + message(FATAL_ERROR "Missing SDK folder: ${SDK_PATH}") diff --git a/x-plane/sam-suite/default.nix b/x-plane/sam-suite/default.nix new file mode 100644 index 0000000..b19eb13 --- /dev/null +++ b/x-plane/sam-suite/default.nix @@ -0,0 +1,36 @@ +{ stdenv, requireFile, openssl, qt5, p7zip, unzip }: + +let + fname = "LINUX_-_SAM_Suite.zip"; + sha256 = "0qf7n910kqsiqcbwvgf87hfhiz4c87pi5xfhw02j4qpcvr2x3ca1"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/59782-scenery-animation-manager-suite/"; + +in qt5.mkDerivation { + pname = "sam"; + version = "1.0"; + src = requireFile { + message = '' + Download the Beautiful Roads Addon from: + ${forumlink} + + Then add it to your nix store, e.g., by using + "nix-prefetch-url file://\$PWD/${fname}" from the directory where you saved it. + ''; + name = fname; + inherit sha256; + }; + nativeBuildInputs = [ unzip ]; + phases = [ "buildPhase" "patchPhase" "configurePhase" "fixupPhase" ]; + nativeBuildInptus = [ unzip ]; + libPath = stdenv.lib.makeLibraryPath [ qt5.qtbase p7zip openssl stdenv.cc.cc ]; + buildPhase = '' + unzip $src others/samsuite.zip + unzip others/samsuite.zip + tar xf samsuite.tar.gz + mkdir -p $out/bin + cp usr/bin/SamSuite $out/bin + cp -r usr/share $out + patchelf --set-rpath "$libPath" --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $out/bin/SamSuite + wrapProgram $out/bin/SamSuite --prefix PATH : ${stdenv.lib.getBin p7zip}/bin + ''; +} diff --git a/x-plane/sam-suite/global-trees.nix b/x-plane/sam-suite/global-trees.nix new file mode 100644 index 0000000..1f20135 --- /dev/null +++ b/x-plane/sam-suite/global-trees.nix @@ -0,0 +1,14 @@ +{ mkXPlaneAddon }: + +mkXPlaneAddon rec { + pname = "sam-global-trees"; + version = "1.0.0"; + + fname = "SAM_GlobalTrees_${version}.7z"; + sha256 = "0w1n90sc0nn8jjmh05rh9q0n149243npi30kghj2hm2ixigij2c4"; + forumlink = "https://sam.stairport-sceneries.com/${fname}"; + buildCommand = '' + mkdir -p $out + 7z x -o$out $src + ''; +} diff --git a/x-plane/sam-suite/sam-basic.nix b/x-plane/sam-suite/sam-basic.nix new file mode 100644 index 0000000..449b2f0 --- /dev/null +++ b/x-plane/sam-suite/sam-basic.nix @@ -0,0 +1,38 @@ +{ stdenv, mkXPlaneAddon, xPlaneEnv }: + +let + inherit (stdenv.lib) findFirst optionalString; + inherit (builtins) isDerivation; + globalTrees = findFirst (k: k.pname == "sam-global-trees") false xPlaneEnv.addons; + +in mkXPlaneAddon rec { + pname = "sam-basic"; + version = "2.0.5"; + + fname = "SAM_${version}.7z"; + sha256 = "1f97r4g5cvhphkr2widcd9w0p5z66lahbjk3cm6rs6y0rvyz66pf"; + forumlink = "https://sam.stairport-sceneries.com/${fname}"; + buildCommand = '' + mkdir -p $out + 7z x -o$out $src + ln -s ${globalTrees} $out/SAM/lib/SAM_GlobalTrees + ''; + + passthru = { + build = '' + ln -s $ADDONPATH $out/xplane-extra/SAM + ''; + # Must be copied because it writes logs + prepare = '' + cp -r --no-preserve=mode -t "$XPLANEPATH/Resources/plugins" /xplane-extra/SAM/SAM + touch "$XPLANEPATH/Resources/plugins/SAM/.prepared" + ''; + revert = '' + if [ -f "$XPLANEPATH/Resources/plugins/SAM/.prepared" ]; then + rm -rf "$XPLANEPATH/Resources/plugins/SAM" + else + false + fi + ''; + }; +} diff --git a/x-plane/sdk.nix b/x-plane/sdk.nix new file mode 100644 index 0000000..7c63463 --- /dev/null +++ b/x-plane/sdk.nix @@ -0,0 +1,13 @@ +{ stdenv, fetchurl, unzip }: + +stdenv.mkDerivation { + pname = "x-plane-sdk"; + version = "2.1.3"; + nativeBuildInputs = [ unzip ]; + src = fetchurl { + url = "http://www.xsquawkbox.net/xpsdk/XPSDK213.zip"; + sha256 = "0z09c0bjimh2b3vh4m14a7vw2laj2g123av2xzsiz804vlcxp5x0"; + }; + phases = [ "unpackPhase" "buildPhase" ]; + buildPhase = "mkdir -p $out; cp -r * $out"; +} diff --git a/x-plane/vivid-sky.nix b/x-plane/vivid-sky.nix new file mode 100644 index 0000000..4dce4a2 --- /dev/null +++ b/x-plane/vivid-sky.nix @@ -0,0 +1,48 @@ +{ stdenv, mkXPlaneAddon }: + +mkXPlaneAddon rec { + pname = "vivid-sky"; + version = "1.1"; + + fname = "Vivid_Sky.zip"; + sha256 = "17x66qsd9ycw1bcp5avh592yqcrlgwzkcx2ly4cqi10504gs1rdx"; + forumlink = "https://forums.x-plane.org/index.php?/files/file/48315-vivid-sky/"; + buildCommand = '' + mkdir -p $out + unzip $src '1. Vivid Sky/Resources/*' '2. Vivid Water (Optional)/*' + mv '1. Vivid Sky/Resources' $out + cp -r '2. Vivid Water (Optional)/Resources' $out + ''; + + passthru = { + build = '' + ln -s $ADDONPATH $out/xplane-extra/vivid-sky + ''; + prepare = '' + mv "$XPLANEPATH/Resources/bitmaps/skycolors" "$XPLANEPATH/Resources/bitmaps/skycolors.orig" + mv "$XPLANEPATH/Resources/bitmaps/world/clouds" "$XPLANEPATH/Resources/bitmaps/world/clouds.orig" + ln -s /xplane-extra/vivid-sky/Resources/bitmaps/skycolors "$XPLANEPATH/Resources/bitmaps/skycolors" + ln -s /xplane-extra/vivid-sky/Resources/bitmaps/world/clouds "$XPLANEPATH/Resources/bitmaps/world/clouds" + mkdir -p "$XPLANEPATH/Resources/plugins/FlyWithLua/Scripts" + ln -sf /xplane-extra/vivid-sky/Resources/plugins/FlyWithLua/Scripts/vivid_sky.lua "$XPLANEPATH/Resources/plugins/FlyWithLua/Scripts/vivid_sky.lua" + ln -sf /xplane-extra/vivid-sky/Resources/plugins/FlyWithLua/Scripts/vivid_water.lua "$XPLANEPATH/Resources/plugins/FlyWithLua/Scripts/vivid_water.lua" + ''; + revert = '' + for f in "$XPLANEPATH/Resources/bitmaps/skycolors" "$XPLANEPATH/Resources/bitmaps/world/clouds" ; do + if [ -L "$f" ]; then + rm "$f" + mv "''${f}.orig" "$f" + else + false + fi + done + for f in "$XPLANEPATH/Resources/plugins/FlyWithLua/Scipts/vivid_sky.lua" "$XPLANEPATH/Resources/plugins/FlyWithLua/Scipts/vivid_water.lua" ; do + if [ -L "$f" ]; then + rm "$f" + else + false + fi + done + ''; + }; +}