<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.11" authoringToolBuild="739" minSpecVersion="1.0">
    <options rootVolumeOnly="true" customize="never" allow-external-scripts="true" hostArchitectures="x86_64,arm64"/>
    <installation-check script="installation_check()"/>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <background-darkAqua file="background-darkAqua" uti="public.png" scaling="proportional" alignment="bottomleft"/>
    <background file="background" uti="public.png" scaling="proportional" alignment="bottomleft"/>
    <welcome file="welcome.rtf"/>
    <license file="license.txt"/>
    <conclusion file="conclusion.rtf"/>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1"/>
    </choices-outline>
    <choice id="installer_choice_1" title="INSTALLER_CHOICE_1_TITLE" description="">
        <pkg-ref id="systems.determinate.pkg.DeterminateNix"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="systems.determinate.pkg.DeterminateNix" version="v0.27.1+pkg.refs/tags/v0.27.1+build.1@5e9dc1bc60ce77023a038ff167321057d0af3adf" auth="Root" installKBytes="0">#Determinate_Nix_Installer.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

	const __IC_FLAT_DISTRIBUTION__=true;
	const IC_CONDITION_EXIST=0;
	const IC_CONDITION_DOES_NOT_EXIST=1;
	const IC_SELECTOR_ANY=0;
	const IC_DISK_TYPE_DESTINATION=0;
	const IC_SELECTOR_ALL=1;
	const IC_DISK_TYPE_STARTUP_DISK=1;

	function IC_CheckFiles(inSelector,inCondition,inDiskType,inFiles)
	{
		var tCount;
		
		tCount=inFiles.length;
		
		if (tCount&gt;0)
		{
			var tIndex;
			var tExists;
			var tPath;
			var atLeastOneTrue=false;
			
			for(tIndex=0;tIndex&lt;tCount;tIndex++)
			{
				tPath=inFiles[tIndex];
			
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tPath=my.target.mountpoint+tPath;
				}
			
				if (system.files.fileExistsAtPath(tPath)==true)
				{
					if (inCondition==IC_CONDITION_EXIST)
					{
						atLeastOneTrue=true;
						
						if (inSelector==IC_SELECTOR_ANY)
						{
							return true;
						}
					}
					else if (inCondition==IC_CONDITION_DOES_NOT_EXIST &amp;&amp; inSelector==IC_SELECTOR_ALL)
					{
						return false;
					}
				}
				else
				{
					if (inCondition==IC_CONDITION_EXIST &amp;&amp; inSelector==IC_SELECTOR_ALL)
					{
						return false;
					}
					else if (inCondition==IC_CONDITION_DOES_NOT_EXIST)
					{
						atLeastOneTrue=true;
						
						if (inSelector==IC_SELECTOR_ANY)
						{
							return true;
						}
					}
				}
			}
		
			return atLeastOneTrue;
		}
		
		return true;
	}

	function installation_check()
	{
		var tResult;

		var tFilesToCheck0=new Array('/nix/receipt.json');

		tResult=IC_CheckFiles(IC_SELECTOR_ANY,IC_CONDITION_DOES_NOT_EXIST,IC_DISK_TYPE_STARTUP_DISK,tFilesToCheck0);

		if (tResult==false)
		{
			my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_1');
			my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_1');
			my.result.type = 'Warn';
		}

		if (tResult==true)
		{
			var tFilesToCheck1=new Array('/nix/var/nix/db/db.sqlite');

			tResult=IC_CheckFiles(IC_SELECTOR_ANY,IC_CONDITION_DOES_NOT_EXIST,IC_DISK_TYPE_STARTUP_DISK,tFilesToCheck1);

			if (tResult==false)
			{
				my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_2');
				my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_2');
				my.result.type = 'Warn';
			}
		}

		return tResult;
	}

    </script>
</installer-gui-script>