#!/usr/bin/env bash


curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovran_SystemsOS_Updater/Updater%20Source%20Files/Intro.md" |
zenity --text-info \
--title="Sovran_SystemsOS Updater" \
--width=1110 \
--height=710

if [[ $? -eq 1 ]]; then
	  
	  exit 1
fi

password=$(zenity --password --title="Sovran_SystemsOS Updater")

	if [ $? -eq 1 ] ; then
			
    exit 2
      
    else

			
		pushd /etc/nixos/

		echo -e "$password" | sudo -S nix flake update

		popd

			
		echo -e "$password" | sudo -S nixos-rebuild switch --impure |
		zenity --progress \
		--no-cancel \
		--auto-close \
		--pulsate \
		--title="Sovran_SystemsOS Updater"

			
		zenity --info \
		--ellipsize \
		--no-wrap \
		--title="Sovran_SystemsOS Updater" \
		--text="Complete! Please Reboot."

	fi

exit 0