refactor hostname preparation to check for existing hostname before NixOS verification
All checks were successful
Nix Format Check / check-format (push) Successful in 39s

This commit is contained in:
2025-01-15 11:49:54 +01:00
parent 1db4d0c49b
commit 325310c1ca

View File

@ -358,18 +358,19 @@ prepare_hostname() {
local hostname local hostname
# Only check for NixOS if hardware configuration is not found # 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
if [ -f "$hostname_file" ]; then hostname=$(cat "$hostname_file")
hostname=$(cat "$hostname_file") log_success "Hostname already found in $hostname_file. Using $hostname."
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 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." die "No hardware configuration found for $hostname. Please create a hardware configuration for this machine."
fi fi
log_success "Hardware configuration found for $hostname. Continuing setup..." log_success "Hardware configuration found for $hostname. Continuing setup..."
return
fi fi
return
fi fi
# Ensure interactive input before hostname prompt # Ensure interactive input before hostname prompt