spacefrogg-overlay/x-plane/sam-suite/sam-basic.nix

39 lines
1.0 KiB
Nix

{ 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
'';
};
}