In case `target_user_ssh_key` points to an empty string, nixos-copy.sh just doesn't set `IdentityFile=` at all. This allows using deploy-nixos without any explicitly passed ssh keys, but picking up whatever ssh setup the user has configured locally. Change-Id: If335ce8434627e61da13bf6923b9767085af08a5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8576 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
		
			
				
	
	
		
			27 lines
		
	
	
	
		
			738 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			738 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| #
 | |
| # Copies a NixOS system to a target host, using the provided key,
 | |
| # or whatever ambient key is configured if the key is not set.
 | |
| set -ueo pipefail
 | |
| 
 | |
| export NIX_SSHOPTS="\
 | |
|     -o StrictHostKeyChecking=no\
 | |
|     -o UserKnownHostsFile=/dev/null\
 | |
|     -o GlobalKnownHostsFile=/dev/null"
 | |
| 
 | |
| # If DEPLOY_KEY was passed, write it to $scratch/id_deploy
 | |
| if [ -n "${DEPLOY_KEY-}" ]; then
 | |
|   scratch="$(mktemp -d)"
 | |
|   trap 'rm -rf -- "${scratch}"' EXIT
 | |
| 
 | |
|   echo -n "$DEPLOY_KEY" > $scratch/id_deploy
 | |
|   chmod 0600 $scratch/id_deploy
 | |
|   export NIX_SSHOPTS="$NIX_SSHOPTS -o IdentityFile=$scratch/id_deploy"
 | |
| fi
 | |
| 
 | |
| nix-copy-closure \
 | |
|   --to ${TARGET_USER}@${TARGET_HOST} \
 | |
|   ${SYSTEM_DRV} \
 | |
|   --gzip \
 | |
|   --include-outputs \
 | |
|   --use-substitutes
 |