feat: allow host to specified in installer

This commit is contained in:
Price Hiller 2023-10-27 02:42:02 -05:00
parent e9bfb11137
commit 2a6dae19d0
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -4,6 +4,7 @@ install() {
set -euo pipefail
local disk="${1}"
local encrypt_disk="${2}"
local host="${3}"
local boot_partition="${disk}1"
local primary_partition="${disk}2"
@ -69,7 +70,7 @@ install() {
# Persistence dir, dirs not to be wiped on reboot stored here
mkdir -p /mnt/nix/persist
# Actually install NixOS
nixos-install --flake "git+file:.#orion"
nixos-install --flake "git+file:.#${host}"
# Finally, clone the flake into the persistent nixos config
git clone . /mnt/nix/persist/etc/nixos/
}
@ -107,6 +108,7 @@ main() {
fi
local disk=""
local host=""
local encrypt_disk="no"
while :; do
@ -131,6 +133,11 @@ main() {
encrypt_disk="yes"
printf "Enabled disk encryption\n"
;;
-H | --host)
shift
host="${1}"
printf "Set host to '%s'\n" "${host}"
;;
-?*)
printf 'Unknown option: %s\n' "$1" >&2
usage
@ -147,14 +154,18 @@ main() {
printf "Value for 'disk' (-d) was not provided! See '--help' for usage!\n"
exit 1
fi
read -r -s -n 1 -p "Press any key to begin NixOS installation to '${disk}'!"
if [[ -z "${host}" ]]; then
printf "Value to 'host' (-H) was not provided! See '--help' for usage!\n"
exit 1
fi
read -r -s -n 1 -p "Press any key to begin NixOS installation to '${disk}' for host '${host}'!"
# printf "\nInstalling in "
# for i in {3..1}; do
# printf "%s.." "${i}"
# sleep 1
# done
# printf "\n"
install "${disk}" "${encrypt_disk}"
install "${disk}" "${encrypt_disk}" "${host}"
}
main "${@}"