From 2a6dae19d0c0f9870ace1835b1e959d38f8a72f1 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 27 Oct 2023 02:42:02 -0500 Subject: [PATCH] feat: allow host to specified in installer --- install.bash | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/install.bash b/install.bash index 3505a11..bf97bda 100644 --- a/install.bash +++ b/install.bash @@ -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 "${@}"