#!/run/current-system/profile/bin/bash

echo "#!/run/current-system/profile/bin/bash" > ./guix-env
echo "" > ./guix-env 

welcome() {
    cat<<"EOF"
    ░░░                                     ░░░
    ░░▒▒░░░░░░░░░               ░░░░░░░░░▒▒░░
     ░░▒▒▒▒▒░░░░░░░           ░░░░░░░▒▒▒▒▒░
         ░▒▒▒░░▒▒▒▒▒         ░░░░░░░▒▒░
               ░▒▒▒▒░       ░░░░░░
                ▒▒▒▒▒      ░░░░░░
                 ▒▒▒▒▒     ░░░░░
                 ░▒▒▒▒▒   ░░░░░
                  ▒▒▒▒▒   ░░░░░
                   ▒▒▒▒▒ ░░░░░
                   ░▒▒▒▒▒░░░░░
                    ▒▒▒▒▒▒░░░
                     ▒▒▒▒▒▒░
   ____ _   _ _____  __  ____  _
  / ___| | | |_ _\ \/ / / ___|| |_ _ __ __ _ _ __
 | |  _| | | || | \  /  \___ \| __| '__/ _` | '_ \
 | |_| | |_| || | /  \   ___) | |_| | | (_| | |_) |
  \____|\___/|___/_/\_\ |____/ \__|_|  \__,_| .__/
                                             |_|
This script installs GNU Guix on your system

https://www.gnu.org/software/guix/
EOF
    echo -n "Press return to continue..."
    read -r  ANSWER
}

cleanup() {
    herd stop cow-store
    umount /mnt/boot/efi
    umount /mnt
    umount /tmp
    cryptsetup close cryptroot
}

welcome
./guix-partition
./guix-crypt
./guix-configure
./guix-prepare
./guix-install
cleanup

echo "GNU Guix has been installed, you can now reboot..."
exit 0