#!/bin/sh -e

RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

echo -e "${YELLOW}Cleaning up old system generations and boot files...${NC}"

# Clean up old generations (older than 7 days)
echo -e "${YELLOW}Removing old system generations...${NC}"
sudo nix-collect-garbage --delete-older-than 7d

# Clean up boot partition by reinstalling bootloader
echo -e "${YELLOW}Cleaning up boot partition...${NC}"
sudo nixos-rebuild boot --flake .#aarch64-linux --install-bootloader

echo -e "${GREEN}Cleanup complete!${NC}"
echo -e "${YELLOW}Boot partition status:${NC}"
df -h /boot
