#!/usr/bin/env bash OMERON_FRESH_INSTALL=0 OMERON_DETECTED_GPU="" module_description() { printf "System Preflight - detect system state and missing dependencies\n" } module_required() { return 0; } module_should_skip() { return 1; } module_prereqs() { require pacman pacman is_arch || { log_error "This module requires an Arch-based system" return 1 } } module_main() { log_section "System Preflight Check" OMERON_DETECTED_GPU="$(detect_gpu)" export OMERON_DETECTED_GPU system_summary if is_fresh_install; then OMERON_FRESH_INSTALL=1 export OMERON_FRESH_INSTALL tui_format "" tui_format "#{bold}#{yellow}⚠ Fresh system detected!#{normal}" tui_format "Hyprland is not installed and no desktop session is running." tui_format "" local gpu_name gpu_name="$(lspci -nn 2>/dev/null | grep -i 'vga\|3d\|display' | sed 's/.*: //' | head -1 || echo "unknown")" tui_format "#{bold}This installation will:#{normal}" tui_format " • Hyprland compositor + tools" tui_format " • GPU drivers for: ${gpu_name}" tui_format " • Audio system (PipeWire)" tui_format " • Network services (NetworkManager)" tui_format " • Fonts and icon themes" tui_format " • Dotfiles deployment" tui_format "" if ! tui_confirm "Proceed with full system setup?"; then log_info "Fresh installation aborted by user" exit 0 fi if ! have paru && ! have yay; then log_info "No AUR helper found. Installing paru..." install_aur_helper fi if ! have gum; then log_info "Installing gum for better TUI..." sudo_run pacman -S --needed --noconfirm gum 2>/dev/null || true tui_style fi log_success "Preflight complete — ready for full installation" else tui_format "" tui_format "#{bold}#{green}✓ Existing Hyprland system detected#{normal}" tui_format "Will check for missing packages and updates." tui_format "" fi } install_aur_helper() { if have paru || have yay; then return 0 fi if ! command -v git >/dev/null 2>&1; then sudo_run pacman -S --needed --noconfirm git base-devel fi local build_dir build_dir="$(mktemp -d)" log_info "Building paru from AUR..." sudo_run pacman -S --needed --noconfirm rustup 2>/dev/null || true if have rustup; then rustup default stable >/dev/null 2>&1 || true fi if git clone https://aur.archlinux.org/paru.git "$build_dir/paru" 2>/dev/null; then (cd "$build_dir/paru" && makepkg -si --needed --noconfirm) 2>&1 | tail -5 || { log_warn "paru build failed, trying yay..." if git clone https://aur.archlinux.org/yay.git "$build_dir/yay" 2>/dev/null; then (cd "$build_dir/yay" && makepkg -si --needed --noconfirm) 2>&1 | tail -5 || { log_warn "yay build failed too. Install manually: paru -S paru-bin" } fi } fi rm -rf "$build_dir" }