From 5b8f307aea5a5a14789480f595e67330f5f882e3 Mon Sep 17 00:00:00 2001 From: shynd Date: Wed, 19 Feb 2025 23:27:54 +0100 Subject: [PATCH] auto-install script --- auto-install.sh | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/auto-install.sh b/auto-install.sh index 671500d..6815a6b 100755 --- a/auto-install.sh +++ b/auto-install.sh @@ -34,7 +34,7 @@ RESET="$(tput sgr0)" set -e if [ -n "$(grep -i nixos < /etc/os-release)" ]; then - echo "${OK} verified distro to be nixos." + echo "${OK} verified distro to be nixos" else echo "$ERROR this is not nixos or the distro info is not available!" exit 1 @@ -44,10 +44,42 @@ if command -v git &> /dev/null; then echo "$OK git is installed, continuing with installation..." echo "-----" else - echo "$ERROR git is not installed, please install git and try again." + echo "$ERROR git is not installed, please install git and try again" fi echo "$NOTE ensure in home directory" cd || exit -echo "-----" \ No newline at end of file +echo "-----" + +backupname=$(date "+%Y-%m-%d-%H-%M-%S") +if [ -d "nixos-config" ]; then + echo "$NOTE nixos-config exists, backing up to nixos-config-backups directory" + if [ -d "nixos-config-backups" ]; then + echo "moving current version of nixos-config to backups directory..." + sudo mv "$HOME"/nixos-config nixos-config-backups/"$backupname" + sleep 1 + else + echo "$NOTE creating the backups directory and moving nixos-config into it..." + mkdir -p nixos-config-backups + sudo mv "$HOME"/nixos-config nixos-config-backups/"$backupname" + sleep 1 + fi +else + echo "$OK proceeding with installation" +fi + +echo "-----" + +echo "$NOTE cloning and entering nixos-config repository" +git clone --depth 1 https://g.r-io.lu/shynd/nixos-config.git ~/nixos-config +cd ~/nixos-config || exit + +printf "\n%.0s" {1..2} + +# check if we're running on a vm and enable option in default config.nix +if hostnamectl | grep -q 'Chassis: vm'; then + echo "${NOTE} your system is running on a vm, enabling guest services..." + echo "${WARN} remember to enable 3D acceleration!" +fi +printf "\n%.0s" {1..1} \ No newline at end of file