Signed-off-by: Christoph Schmatzler <christoph@schmatzler.com>
This commit is contained in:
2025-08-23 16:37:54 +00:00
parent acd58a2f53
commit 3d127819ea
16 changed files with 252 additions and 633 deletions

View File

@@ -1,24 +1,41 @@
#!/bin/sh -e
#!/usr/bin/env bash
GREEN='\033[1;32m'
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[1;31m'
BLUE='\033[0;34m'
NC='\033[0m'
FLAKE="macos"
print_info() {
echo -e "${BLUE} ${NC} $1"
}
echo "${YELLOW}Available generations:${NC}"
/run/current-system/sw/bin/darwin-rebuild --list-generations
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
echo "${YELLOW}Enter the generation number for rollback:${NC}"
read GEN_NUM
print_error() {
echo -e "${RED}✗${NC} $1"
}
if [ -z "$GEN_NUM" ]; then
echo "${RED}No generation number entered. Aborting rollback.${NC}"
exit 1
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_info "Available generations:"
darwin-rebuild --list-generations
echo -n "Enter generation number to rollback to: "
read -r GEN_NUM
if [[ -z "$GEN_NUM" ]]; then
print_error "No generation number provided"
exit 1
fi
echo "${YELLOW}Rolling back to generation $GEN_NUM...${NC}"
/run/current-system/sw/bin/darwin-rebuild switch --flake .#$FLAKE --switch-generation $GEN_NUM
print_warning "Rolling back to generation $GEN_NUM..."
darwin-rebuild switch --switch-generation "$GEN_NUM"
echo "${GREEN}Rollback to generation $GEN_NUM complete!${NC}"
print_success "Rollback to generation $GEN_NUM complete"