#!/usr/bin/env bash # Quick ISO build test script set -e echo "๐Ÿงช OmniXY ISO Build Test" echo "========================" echo "" # Check if we're in the right directory if [ ! -f "flake.nix" ] || [ ! -f "iso.nix" ]; then echo "โŒ Error: Must be run from the OmniXY project root directory" echo " Expected files: flake.nix, iso.nix" exit 1 fi # Check if nix is available if ! command -v nix &> /dev/null; then echo "โŒ Error: Nix is not installed or not in PATH" exit 1 fi # Check flakes support if ! nix --help | grep -q flakes; then echo "โŒ Error: Nix flakes not enabled" echo " Add 'experimental-features = nix-command flakes' to nix.conf" exit 1 fi echo "โœ… Environment checks passed" echo "" # Test flake evaluation echo "๐Ÿ” Testing flake evaluation..." if nix flake check --no-build 2>/dev/null; then echo "โœ… Flake configuration is valid" else echo "โš ๏ธ Flake check warnings (this is usually fine for ISO builds)" fi echo "" # Test ISO configuration evaluation echo "๐Ÿ” Testing ISO configuration..." if nix eval .#nixosConfigurations.omnixy-iso --apply 'config: "ISO config loads successfully"' &>/dev/null; then echo "โœ… ISO configuration evaluates successfully" else echo "โŒ ISO configuration has evaluation errors" echo " Try: nix eval .#nixosConfigurations.omnixy-iso --show-trace" exit 1 fi echo "" # Estimate build requirements echo "๐Ÿ“Š Build Requirements:" echo " โ€ข Disk space: ~10-15 GB during build, ~3-5 GB for final ISO" echo " โ€ข RAM: Recommended 8+ GB (minimum 4 GB)" echo " โ€ข Time: 30-60 minutes on first build (varies by system)" echo " โ€ข Network: Several GB of downloads on first build" echo "" # Ask if user wants to proceed with actual build read -p "๐Ÿš€ Do you want to proceed with building the ISO? (y/N): " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then echo "๐Ÿ—๏ธ Starting ISO build..." echo " This may take a while. Press Ctrl+C to cancel." echo "" # Start the build with progress if nix build .#iso --print-build-logs; then echo "" echo "โœ… ISO build completed successfully!" # Find and display the ISO if [ -L "./result" ]; then iso_path=$(readlink -f ./result) iso_file=$(find "$iso_path" -name "*.iso" | head -1) if [ -n "$iso_file" ]; then iso_size=$(du -h "$iso_file" | cut -f1) echo "๐Ÿ“ ISO Location: $iso_file" echo "๐Ÿ“ ISO Size: $iso_size" echo "" echo "๐Ÿš€ Next steps:" echo " โ€ข Test in VM: qemu-system-x86_64 -cdrom '$iso_file' -m 4G -enable-kvm" echo " โ€ข Flash to USB: sudo dd if='$iso_file' of=/dev/sdX bs=4M status=progress" echo " โ€ข See BUILD_ISO.md for complete documentation" else echo "โš ๏ธ ISO file not found in build result" fi else echo "โš ๏ธ Build result symlink not found" fi else echo "" echo "โŒ ISO build failed" echo " Check the error messages above for details" echo " Common solutions:" echo " โ€ข Free up disk space: nix-collect-garbage -d" echo " โ€ข Check internet connection" echo " โ€ข Try again (builds can sometimes fail on first attempt)" exit 1 fi else echo "๐Ÿ›‘ Build cancelled. You can run this test anytime with:" echo " ./test-iso-build.sh" echo "" echo "To build manually:" echo " nix build .#iso" echo " nix run .#build-iso" fi echo "" echo "๐Ÿ“š For more information, see BUILD_ISO.md"