deploy: Colorize steps
This commit is contained in:
parent
50abb95e4c
commit
875ea5d137
|
@ -4,20 +4,34 @@ verb="$2"
|
|||
shift
|
||||
shift
|
||||
|
||||
# Helpers
|
||||
error() {
|
||||
echo -e '\033[1;31m'"$*"'\033[0m'
|
||||
}
|
||||
warn() {
|
||||
echo -e '\033[1;33m'"$*"'\033[0m'
|
||||
}
|
||||
info() {
|
||||
echo -e '\033[1;34m'"$*"'\033[0m'
|
||||
}
|
||||
debug() {
|
||||
[ ! -v DEBUG ] || echo -e '\033[1;35m'"$*"'\033[0m'
|
||||
}
|
||||
|
||||
if [ "$verb" != "build" ] && [ "$verb" != "test" ] && [ "$verb" != "boot" ] && [ "$verb" != "switch" ] && [ "$verb" != "confirm" ]
|
||||
then
|
||||
echo "Action should be one of: build, test, boot, switch, confirm"
|
||||
error "Action should be one of: build, test, boot, switch, confirm"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Build, looking nice
|
||||
info "Building"
|
||||
tmpdir="$(mktemp -d)"
|
||||
# sudo so the eval cache is shared with nixos-rebuild
|
||||
sudo nom build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" -o "$tmpdir/toplevel" "$@"
|
||||
toplevel="$(readlink -f "$tmpdir/toplevel")"
|
||||
rm -rf "$tmpdir"
|
||||
|
||||
# Show diff
|
||||
info "Showing diff"
|
||||
nvd diff "$(readlink -f /nix/var/nix/profiles/system)" "$toplevel"
|
||||
|
||||
# Figure out specialisation
|
||||
|
@ -27,15 +41,17 @@ while read -r specialisation
|
|||
do
|
||||
if [ "$(readlink -f "/nix/var/nix/profiles/system/specialisation/$specialisation")" = "$currentSystem" ]
|
||||
then
|
||||
debug "Using specialisation: $specialisation"
|
||||
specialisationArgs=("--specialisation" "$specialisation")
|
||||
fi
|
||||
done <<< "$(ls /nix/var/nix/profiles/system/specialisation)"
|
||||
|
||||
# Apply
|
||||
info "Applying"
|
||||
confirm="n"
|
||||
if [ "$verb" = "confirm" ]
|
||||
then
|
||||
echo "Apply configuration? [y/N]"
|
||||
warning "Apply configuration? [y/N]"
|
||||
read -r confirm
|
||||
fi
|
||||
if [ "$verb" = "test" ] || [ "$verb" = "switch" ] || [ "$confirm" = "y" ]
|
||||
|
@ -47,7 +63,7 @@ fi
|
|||
# Set as boot
|
||||
if [ "$verb" = "confirm" ]
|
||||
then
|
||||
echo "Set configuration as boot? [y/N]"
|
||||
warning "Set configuration as boot? [y/N]"
|
||||
read -r confirm
|
||||
fi
|
||||
if [ "$verb" = "boot" ] || [ "$verb" = "switch" ] || [ "$confirm" = "y" ]
|
||||
|
|
Loading…
Reference in a new issue