#!/bin/bash

# Miasma OS installer bootstrap script
# This script is designed to be run from within an Arch ISO environment

set -e

# Check if we're running in Arch ISO environment
if ! command -v pacman &> /dev/null; then
    echo "Error: This installer must be run from Arch Linux environment"
    exit 1
fi

# Install dependencies
echo "Installing dependencies..."
pacman -Sy --noconfirm go git

# Build the Miasma installer
echo "Building Miasma installer..."
cd /tmp
git clone https://github.com/miasma-os/miasma-installer.git
cd miasma-installer
make build

# Install to system
echo "Installing to system..."
sudo make install

echo "Miasma installer installed successfully!"
echo "Run 'sudo miasma-installer' to start installation"

exit 0