nixfiles/scripts/rebuild.sh

24 lines
560 B
Bash
Raw Normal View History

#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
REPO_ROOT="${SCRIPT_DIR}/.."
cd $REPO_ROOT
# re-run as root
if [ "$EUID" -ne 0 ]; then
sudo ${BASH_SOURCE[0]} $@
exit
fi
2024-07-24 16:15:46 +01:00
MODE=""
if [ -z "${1-}" ]; then
2023-09-20 19:05:44 +01:00
MODE=switch
fi
2024-07-24 16:15:46 +01:00
if command -v nom &> /dev/null; then
nixos-rebuild --flake "${REPO_ROOT}#$(hostname)" "$MODE" "$@" --keep-failed --log-format internal-json -v |& nom --json
else
echo "Install nix-output-monitor for better output"
nixos-rebuild --flake "${REPO_ROOT}#$(hostname)" "$MODE" "$@"
fi