remove deploy.sh
This commit is contained in:
parent
2b3fedab68
commit
773a38ce67
1 changed files with 0 additions and 97 deletions
97
deploy
97
deploy
|
|
@ -1,97 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# TODO: use `nixos-rebuild build-vm`
|
|
||||||
|
|
||||||
usage="Usage: $(basename $0) [OPTIONS]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-f, --fresh Remove old content in the nixstore (good for debugging)
|
|
||||||
-b, --bootloader Reinstall the bootloader
|
|
||||||
-r, --remote Locally build and remotely deploy Colmena hive
|
|
||||||
--show-trace Show nix stack trace on error
|
|
||||||
-h, --help Show this message (^_^)"
|
|
||||||
|
|
||||||
# delete all cached entries
|
|
||||||
# to make the system from scratch
|
|
||||||
collect_garbage () {
|
|
||||||
sudo nix-collect-garbage --delete-old
|
|
||||||
}
|
|
||||||
|
|
||||||
rebuild_flake () {
|
|
||||||
# make sure all changes are visible to nixos
|
|
||||||
# (--intent-to-add tracks files but DOES NOT stage them)
|
|
||||||
git add . --intent-to-add --verbose
|
|
||||||
local FLAGS=
|
|
||||||
if [ "$1" = "reinstall-bootloader" ]; then
|
|
||||||
FLAGS="--install-bootloader"
|
|
||||||
# sudo nixos-rebuild switch --flake . --install-bootloader
|
|
||||||
# STC_DISPLAY_ALL_UNITS=1 (verbose, show output of all units)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# LOG="$(mktemp /tmp/rebuild-XXXXXXXX)"
|
|
||||||
LOG="./rebuild.log"
|
|
||||||
echo "[*] Logging to $LOG"
|
|
||||||
sudo nixos-rebuild switch --flake . $FLAGS $EXTRA_FLAGS 2>&1 | tee "$LOG"
|
|
||||||
#nixos-rebuild build --flake .# --cores 8 -j 1
|
|
||||||
}
|
|
||||||
|
|
||||||
deploy_hive () {
|
|
||||||
echo "[+] Adding keys to ssh-agent"
|
|
||||||
ssh-add ~/.ssh/id_hyrule
|
|
||||||
printf "\n"
|
|
||||||
|
|
||||||
git add . --verbose
|
|
||||||
# Deploy to all Colmena hives
|
|
||||||
colmena build --experimental-flake-eval $EXTRA_FLAGS
|
|
||||||
colmena apply --experimental-flake-eval $EXTRA_FLAGS
|
|
||||||
# colmena apply --on hyrule --experimental-flake-eval
|
|
||||||
}
|
|
||||||
|
|
||||||
# check which flags were given
|
|
||||||
flag_fresh=false
|
|
||||||
flag_bootloader=false
|
|
||||||
flag_remote=false
|
|
||||||
flag_trace=false
|
|
||||||
for flag in "$@"; do
|
|
||||||
case "$flag" in
|
|
||||||
-r|--remote)
|
|
||||||
flag_remote=true ;;
|
|
||||||
--show-trace)
|
|
||||||
flag_trace=true ;;
|
|
||||||
-f|--fresh)
|
|
||||||
flag_fresh=true ;;
|
|
||||||
-b|--bootloader)
|
|
||||||
flag_bootloader=true ;;
|
|
||||||
-h|--help)
|
|
||||||
echo "$usage"
|
|
||||||
exit 0 ;;
|
|
||||||
*)
|
|
||||||
echo "[!] Unknown flag \"$flag\""
|
|
||||||
exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
EXTRA_FLAGS=""
|
|
||||||
if [ "$flag_trace" = true ]; then
|
|
||||||
EXTRA_FLAGS="$EXTRA_FLAGS --show-trace"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$flag_remote" = true ]; then
|
|
||||||
deploy_hive
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# delete cached items in nixstore
|
|
||||||
if [ "$flag_fresh" = true ]; then
|
|
||||||
collect_garbage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# nixos-rebuild switch ...
|
|
||||||
if [ "$flag_bootloader" = true ]; then
|
|
||||||
collect_garbage
|
|
||||||
rebuild_flake "reinstall-bootloader"
|
|
||||||
else
|
|
||||||
rebuild_flake
|
|
||||||
fi
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue