This adds an additional parameter `entrypoint`, pointing to a .nix file (or a directory containing a `default.nix` file) that's providing the attribute path asked for. If not set / kept at the default (empty string), it falls back to the root dir of the repository as before. Change-Id: I2e63114f21660c842153ac15424b3491d66624d2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8190 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
		
			
				
	
	
		
			15 lines
		
	
	
	
		
			524 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
	
		
			524 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| #
 | |
| # Builds a NixOS system configuration at the given attribute path.
 | |
| set -ueo pipefail
 | |
| 
 | |
| # Load input variables from Terraform. jq's @sh format takes care of
 | |
| # escaping.
 | |
| eval "$(jq -r '@sh "ATTRPATH=\(.attrpath) && ENTRYPOINT=\(.entrypoint)"')"
 | |
| 
 | |
| # Evaluate the system derivation.
 | |
| [[ -z "$ENTRYPOINT" ]] && ENTRYPOINT=$(git rev-parse --show-toplevel)
 | |
| SYSTEM_DRV=$(nix-instantiate -A "${ATTRPATH}" "${ENTRYPOINT}")
 | |
| 
 | |
| # Return system derivation back to Terraform.
 | |
| jq -n --arg drv "$SYSTEM_DRV" '{"drv":$drv}'
 |