From 65cfc4c6096a55835f88c92e7434f02e598bd018 Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Tue, 31 Dec 2024 06:13:23 -0500 Subject: [PATCH] 135 current 2024-12-31 06:13:16 25.05.20241217.d3c42f1 6.6.66 * --- home/scripts/nixos-rebuild.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/home/scripts/nixos-rebuild.sh b/home/scripts/nixos-rebuild.sh index 2cb6d9a..6eeb905 100644 --- a/home/scripts/nixos-rebuild.sh +++ b/home/scripts/nixos-rebuild.sh @@ -24,13 +24,23 @@ alejandra . &>/dev/null \ git --git-dir /home/synchronous/nix-cfg/.git --no-pager diff -U0 # '*.nix' -# Rebuild, output simplified errors, log trackebacks -sudo nixos-rebuild switch --flake /home/synchronous/nix-cfg/flake.nix &> /tmp/nixos-switch.log -cat /tmp/nixos-switch.log | grep --color error && exit 1 - echo "" echo "NixOS Rebuilding..." +# Rebuild, output simplified errors, log trackebacks +sudo nixos-rebuild switch --flake /home/synchronous/nix-cfg/flake.nix &> /tmp/nixos-switch.log +# cat /tmp/nixos-switch.log | grep --color error && exit 1 + +if grep --color error /tmp/nixos-switch.log; then + # cat /tmp/nixos-switch.log | grep --color error + read -p "Would you like to view the error log? (y/n): " choice + choice=${choice:-n} + if [[ "$choice" == "y" || "$choice" == "Y" ]]; then + cat /tmp/nixos-switch.log + fi + exit 1; +fi + # Get current generation metadata current=$(nixos-rebuild list-generations | grep current)