From 325310c1ca68d22b3f8804335691b3cfcee9fe4e Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Wed, 15 Jan 2025 11:49:54 +0100 Subject: [PATCH] refactor hostname preparation to check for existing hostname before NixOS verification --- setup.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 064e0a8..821d2b4 100755 --- a/setup.sh +++ b/setup.sh @@ -358,18 +358,19 @@ prepare_hostname() { local hostname # Only check for NixOS if hardware configuration is not found - if command -v nixos-version >/dev/null 2>&1; then - if [ -f "$hostname_file" ]; then - hostname=$(cat "$hostname_file") - log_success "Hostname already found in $hostname_file. Using $hostname." - + if [ -f "$hostname_file" ]; then + hostname=$(cat "$hostname_file") + log_success "Hostname already found in $hostname_file. Using $hostname." + + if command -v nixos-version >/dev/null 2>&1; then if [ ! -f "$DOTFILES_DIR/config/nixos/hardware/$hostname.nix" ]; then die "No hardware configuration found for $hostname. Please create a hardware configuration for this machine." fi - + log_success "Hardware configuration found for $hostname. Continuing setup..." - return fi + + return fi # Ensure interactive input before hostname prompt