Files
dotfiles/bin/actions/upgrade.sh
Menno van Leeuwen 76e9cb0371
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
adds swap to all devices
adds noatime to all devices root partition mount options
adds cosmic desktop to workstations
adds xanmod kernel to workstations
adds xanmod with zfs to servers
adds perplexityai extension to brave
removes openra flatpak
adds threads limit to upgrade command to prevent system freezes
removes fcitx5 completely
2024-12-11 14:51:35 +01:00

51 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
source $HOME/dotfiles/bin/helpers/functions.sh
while [[ "$#" -gt 0 ]]; do
case $1 in
--ha) RUN_HA=true ;;
--nix) RUN_NIX=true ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [[ -z "$RUN_HA" && -z "$RUN_NIX" ]]; then
RUN_HA=true
RUN_NIX=true
fi
# Check if --full-speed flag is passed, otherwise use --cores 8 -j 1
if [[ "$1" == "--full-speed" ]]; then
CORES=$(nproc)
JOBS=$(nproc)
else
CORES=8
JOBS=1
fi
printfe "%s\n" "cyan" "Limiting to $CORES cores with $JOBS jobs."
if [[ "$RUN_NIX" == true ]]; then
printfe "%s\n" "cyan" "Upgrading NixOS packages..."
cd $HOME/dotfiles/config/nixos && sudo nixos-rebuild switch --upgrade --flake .#$DOTF_HOSTNAME --impure --cores $CORES -j $JOBS
if [[ $? -ne 0 ]]; then
printfe "%s\n" "red" "Failed to upgrade NixOS packages."
exit 1
fi
fi
if [[ "$RUN_HA" == true ]]; then
printfe "%s\n" "cyan" "Cleaning old backup files..."
rm -rf $HOME/.config/mimeapps.list.backup
printfe "%s\n" "cyan" "Upgrading Home Manager packages..."
cd $HOME/dotfiles/config/home-manager && NIXPKGS_ALLOW_UNFREE=1 home-manager switch -b backup --flake .#$DOTF_HOSTNAME --impure --cores $CORES -j $JOBS
if [[ $? -ne 0 ]]; then
printfe "%s\n" "red" "Failed to upgrade Home Manager packages."
exit 1
fi
fi