Updated ncli to represet generations with colors.
This commit is contained in:
@ -20,6 +20,9 @@ in
|
|||||||
|
|
||||||
read -r -a BACKUP_FILES <<< "$BACKUP_FILES_STR"
|
read -r -a BACKUP_FILES <<< "$BACKUP_FILES_STR"
|
||||||
|
|
||||||
|
# --- Read Colors file ---
|
||||||
|
source /$HOME/$PROJECT/other/colors.sh
|
||||||
|
|
||||||
# --- Helper Functions ---
|
# --- Helper Functions ---
|
||||||
print_help() {
|
print_help() {
|
||||||
echo "NixOS CLI Utility -- version $VERSION"
|
echo "NixOS CLI Utility -- version $VERSION"
|
||||||
@ -127,7 +130,7 @@ in
|
|||||||
rebuild)
|
rebuild)
|
||||||
handle_backups
|
handle_backups
|
||||||
geno=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
geno=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
||||||
echo "Starting NixOS rebuild for current host: $HOST on generation: $geno"
|
echo -e "Starting NixOS rebuild for current host: $HOST on generation: $YELLOW$geno$NOCOLOR"
|
||||||
cd "$HOME/$PROJECT" || { echo "Error: Could not change to $HOME/$PROJECT"; exit 1; }
|
cd "$HOME/$PROJECT" || { echo "Error: Could not change to $HOME/$PROJECT"; exit 1; }
|
||||||
|
|
||||||
current=""
|
current=""
|
||||||
@ -145,7 +148,7 @@ in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
genn=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
genn=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
||||||
echo "Running on new generation: $geno -> $genn"
|
echo -e "Running on new generation: $YELLOW $geno $NOCOLOR-> $GREEN$genn$NOCOLOR"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "✗ Rebuild failed for $HOST" >&2
|
echo "✗ Rebuild failed for $HOST" >&2
|
||||||
@ -155,7 +158,7 @@ in
|
|||||||
update)
|
update)
|
||||||
handle_backups
|
handle_backups
|
||||||
geno=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
geno=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
||||||
echo "Updating flake and rebuilding system for current host: $HOST on generation: $geno"
|
echo -e "Updating flake and rebuilding system for current host: $HOST on generation: $YELLOW$geno$NOCOLOR"
|
||||||
cd "$HOME/$PROJECT" || { echo "Error: Could not change to $HOME/$PROJECT"; exit 1; }
|
cd "$HOME/$PROJECT" || { echo "Error: Could not change to $HOME/$PROJECT"; exit 1; }
|
||||||
|
|
||||||
echo "Updating flake..."
|
echo "Updating flake..."
|
||||||
@ -188,7 +191,7 @@ in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
genn=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
genn=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}')
|
||||||
echo "Running on new generation: $geno -> $genn"
|
echo -e "Running on new generation: $YELLOW $geno $NOCOLOR-> $GREEN$genn$NOCOLOR"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "✗ Update and rebuild failed for $HOST" >&2
|
echo "✗ Update and rebuild failed for $HOST" >&2
|
||||||
@ -260,7 +263,7 @@ in
|
|||||||
;;
|
;;
|
||||||
trim)
|
trim)
|
||||||
echo "Running 'sudo fstrim -v /' may take a few minutes and impact system performance."
|
echo "Running 'sudo fstrim -v /' may take a few minutes and impact system performance."
|
||||||
read -p "Enter (y/Y) to run now or enter to exit (y/N): " -n 1 -r
|
read -p "Enter to run now or enter to exit (y/N): " -n 1 -r
|
||||||
echo # move to a new line
|
echo # move to a new line
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
echo "Running fstrim..."
|
echo "Running fstrim..."
|
||||||
|
|||||||
Reference in New Issue
Block a user