From d48a3d3925f194890f96640e68e189c3f6eede67 Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Wed, 15 Jan 2025 11:45:14 +0100 Subject: [PATCH] refactor hostname preparation to check for NixOS only when hardware configuration is absent --- setup.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/setup.sh b/setup.sh index d0294b5..c60b5b9 100755 --- a/setup.sh +++ b/setup.sh @@ -353,16 +353,19 @@ prepare_hostname() { local hostname_file="$HOME/.hostname" local hostname - if [ -f "$hostname_file" ]; then - hostname=$(cat "$hostname_file") - log_success "Hostname already found in $hostname_file. Using $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 "$DOTFILES_DIR/config/nixos/hardware/$hostname.nix" ]; then - die "No hardware configuration found for $hostname. Please create a hardware configuration for this machine." + 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 - - log_success "Hardware configuration found for $hostname. Continuing setup..." - return fi # Ensure interactive input before hostname prompt