nixbook/update_lite.sh

29 lines
868 B
Bash
Raw Permalink Normal View History

2025-02-14 16:06:10 -05:00
echo "This will update your Nixbook and reboot";
read -p "Do you want to continue? (y/n): " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "Updating Nixbook..."
# Download the latest nixbook changes
sudo git -C /etc/nixbook reset --hard
sudo git -C /etc/nixbook clean -fd
2025-02-14 18:28:32 -05:00
sudo git -C /etc/nixbook pull --rebase
2025-02-14 16:06:10 -05:00
# Update the nixos nix-channel to be the same as config.system.autoUpgrade.channel in base.nix or base_lite.nix
AUTOUPDATE_CHANNEL="$(sudo nix-instantiate --eval '<nixpkgs/nixos>' -A config.system.autoUpgrade.channel | tr -d '"')"
sudo nix-channel --add "${AUTOUPDATE_CHANNEL}" nixos
# Free up space before updates
nix-collect-garbage --delete-older-than 14d
# get the updates
sudo nixos-rebuild boot --upgrade
# free up a little more space with hard links
nix-store --optimise
reboot
else
echo "Update Cancelled!"
fi