#!/usr/bin/env bash set -euo pipefail # Numbus Installer Bootstrap # This script clones the repository and launches the NixOS deployment script. REPO_URL="https://gittea.dev/numbus/numbus.git" INSTALL_DIR="/run/user/$(id -u)/numbus-installer" BRANCH="${BRANCH:-production}" echo -e "\n ☁️ Initializing Numbus Installer..." # 1. Check for Nix TEST_FAIL=0 if [[ -r /etc/os-release ]] && grep -qi '^ID=nixos\b' /etc/os-release; then echo -e "\n ✅ NixOS system detected." else TEST_FAIL=$((TEST_FAIL + 1)) echo -e "\n ❌ You are not on a NixOS based system. This is required to continue." fi if [[ "$(uname -m)" == "x86_64" ]]; then echo -e "\n ✅ x86_64 system detected." else TEST_FAIL=$((TEST_FAIL + 1)) echo -e "\n ❌ You are not on a x86_64 based system. This is required to continue." fi if [[ ${TEST_FAIL} -gt 0 ]]; then COMPATIBILITY_OVERRIDE=$(gum choose --header "Some compatibility checks failed. The installation will VERY LIKELY fail. Continue ?" \ "No" \ "Yes, I know what I am doing") [[ "${COMPATIBILITY_OVERRIDE}" == "No" ]] && exit 1 echo -e "\n ⚠️ Continuing anyways, this is not supported by Numbus." fi # 2. Clone/Update the repository if [[ -e ${INSTALL_DIR}/config/* ]]; then echo " ⚠️ It seems you have already run this script. Previously generated files need to be cleaned up." OLD_CONFIG_PATH="${INSTALL_DIR}/trash/$(date +"%Y-%m-%d-%Hh%M")" mkdir -p ${OLD_CONFIG_PATH} mv ${INSTALL_DIR} ${OLD_CONFIG_PATH} echo " ✅ Your files have been moved to the ${OLD_CONFIG_PATH} directory. You can retrieve them there if needed." else rm -rf "${INSTALL_DIR}" fi git clone -b "${BRANCH}" "${REPO_URL}" "${INSTALL_DIR}" -q # 3. Launch the deployment script cd "${INSTALL_DIR}/script" chmod +x deploy.sh ./deploy.sh