58 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| # Script to consistently install configuration.nix.
 | |
| # To be called by Ansible via setup.sh and nixos.yml, as well as CLI by users.
 | |
| 
 | |
| ## Variables ##
 | |
| 
 | |
| DIR="$(dirname -- "${BASH_SOURCE[0]}")"
 | |
| PROG="$(basename -- "${BASH_SOURCE[0]}")"
 | |
| 
 | |
| nixos_working_dir=~/nixos-config-deleteme
 | |
| nixos_working_exe=activate.sh
 | |
| 
 | |
| ## Functions ##
 | |
| 
 | |
| function usage {
 | |
| 	echo -e "\nUsage: $PROG -b BRANCH" >&2
 | |
| 	cat <<- EOF
 | |
| 		Run a setup script for NixOS based on the https://git.hyperling.com/me/env-nixos project.
 | |
| 
 | |
| 		Parameters:
 | |
| 		  -b BRANCH: The branch which should be installed, likely 'main' or 'dev'.
 | |
| 	EOF
 | |
| 	echo ""
 | |
| 	exit $1
 | |
| }
 | |
| 
 | |
| function cleanup {
 | |
| 	sh -c "rm -rfv $nixos_working_dir" >/dev/null
 | |
| }
 | |
| 
 | |
| ## Parameters ##
 | |
| 
 | |
| while getopts ":b:h" opt; do
 | |
| 	case $opt in
 | |
| 		b) branch="$OPTARG" ;;
 | |
| 		h) usage 0 ;;
 | |
| 		*) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;;
 | |
| 	esac
 | |
| done
 | |
| 
 | |
| if [[ -z $branch ]]; then
 | |
| 	echo "ERROR: Branch is required. $branch" >&2
 | |
| 	usage 2
 | |
| fi
 | |
| 
 | |
| ## Main ##
 | |
| 
 | |
| cleanup
 | |
| 
 | |
| # Install the Hyperling NixOS configurations.
 | |
| git clone https://git.hyperling.com/me/env-nixos --branch $branch $nixos_working_dir
 | |
| chmod 755 $nixos_working_dir/$nixos_working_exe
 | |
| $nixos_working_dir/$nixos_working_exe
 | |
| 
 | |
| cleanup
 | |
| 
 | |
| exit 0
 |