- Simplified command cases by removing unnecessary semicolons.
- Improved error handling in rebuild.nix for clarity and consistency.
This commit is contained in:
@ -1,10 +1,7 @@
|
||||
# ncli/commands/rebuild.nix — Rebuild + Update logic
|
||||
lib:
|
||||
|
||||
let
|
||||
lib: let
|
||||
inherit (lib) host project handle_backups handle_build_error;
|
||||
in
|
||||
{
|
||||
in rec {
|
||||
# Shared rebuild snippet used by both `rebuild` and `update`
|
||||
rebuild_logic = ''
|
||||
handle_backups
|
||||
@ -21,7 +18,10 @@ in
|
||||
${rebuild_logic}
|
||||
echo -e "Starting NixOS rebuild for current host: ${host} on generation: $YELLOW$geno$NOCOLOR"
|
||||
|
||||
sudo nixos-rebuild switch --flake . ; _rebuild_exit=$?
|
||||
set +e
|
||||
sudo nixos-rebuild switch --flake .
|
||||
_rebuild_exit=$?
|
||||
set -e
|
||||
if [ "$_rebuild_exit" -eq 0 ]; then
|
||||
echo "✓ Rebuild finished successfully for ${host}"
|
||||
|
||||
@ -38,7 +38,6 @@ in
|
||||
echo "✗ Rebuild failed for ${host}" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
'';
|
||||
|
||||
update_case = ''
|
||||
@ -110,7 +109,10 @@ in
|
||||
echo "Rebuilding system... Staying on current specialization"
|
||||
fi
|
||||
|
||||
sudo nixos-rebuild switch --flake . ; _rebuild_exit=$?
|
||||
set +e
|
||||
sudo nixos-rebuild switch --flake .
|
||||
_rebuild_exit=$?
|
||||
set -e
|
||||
if [ "$_rebuild_exit" -eq 0 ]; then
|
||||
echo "✓ Update and rebuild finished successfully for ${host}"
|
||||
|
||||
@ -127,6 +129,5 @@ in
|
||||
echo "✗ Update and rebuild failed for ${host}" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user