diff --git a/hosts/template2/bootstrap.nix b/hosts/template2/bootstrap.nix index 8aac949..07bd829 100644 --- a/hosts/template2/bootstrap.nix +++ b/hosts/template2/bootstrap.nix @@ -6,11 +6,18 @@ let text = '' set -euo pipefail + # Clear screen and show bootstrap banner + clear + echo "================================================================================" + echo " NIXOS BOOTSTRAP IN PROGRESS" + echo "================================================================================" + echo "" + # Read hostname set by cloud-init (from Terraform VM name via user-data) # Cloud-init sets the system hostname from user-data.txt, so we read it from hostnamectl HOSTNAME=$(hostnamectl hostname) - echo "DEBUG: Hostname from hostnamectl: '$HOSTNAME'" - + echo "Hostname: $HOSTNAME" + echo "" echo "Starting NixOS bootstrap for host: $HOSTNAME" echo "Waiting for network connectivity..." @@ -93,6 +100,21 @@ let }; in { + # Custom greeting line to indicate this is a bootstrap image + services.getty.greetingLine = lib.mkForce '' + ================================================================================ + BOOTSTRAP IMAGE - NixOS \V (\l) + ================================================================================ + + Bootstrap service is running. Logs are displayed on tty1. + Check status: journalctl -fu nixos-bootstrap + ''; + + # Disable getty on tty1 so bootstrap output is visible + systemd.services."getty@tty1" = { + enable = false; + }; + systemd.services."nixos-bootstrap" = { description = "Bootstrap NixOS configuration from flake on first boot"; @@ -107,14 +129,17 @@ in serviceConfig = { Type = "oneshot"; RemainAfterExit = true; - ExecStart = "${bootstrap-script}/bin/nixos-bootstrap"; + ExecStart = lib.getExe bootstrap-script; # Read environment variables from cloud-init (set by cloud-init write_files) EnvironmentFile = "-/run/cloud-init-env"; - # Logging to journald - StandardOutput = "journal+console"; - StandardError = "journal+console"; + # Output to tty1 for visibility on console + StandardOutput = "tty"; + StandardError = "tty"; + TTYPath = "/dev/tty1"; + TTYReset = true; + TTYVHangup = true; }; }; }