- Simplified command cases by removing unnecessary semicolons.

- Improved error handling in rebuild.nix for clarity and consistency.
This commit is contained in:
2026-05-29 09:29:31 +02:00
parent d989792774
commit 134fc441a5
8 changed files with 435 additions and 447 deletions

View File

@ -18,33 +18,35 @@
# --- Help text ---
print_help = ''
echo "NixOS CLI Utility -- version 2.1.3"
echo ""
echo "Usage: ncli [command]"
echo ""
echo "System Commands:"
echo " rebuild - Rebuild the NixOS system configuration."
echo " update - Update the flake and rebuild the system."
echo ""
echo "Maintenance Commands:"
echo " cleanup - Clean up old system generations. Can specify a number to keep."
echo " diag - Create a system diagnostic report (saves to ~/diag.txt)."
echo " list-gens - List user and system generations."
echo " trim - Trim filesystems to improve SSD performance."
echo ""
echo "Git Commands:"
echo " commit [msg] - Add all changes and commit with message."
echo " push - Push changes to origin."
echo " pull - Pull latest changes from origin."
echo " status - Show git status."
echo ""
echo "Development Commands:"
echo " dev - Initialize a Nix development environment (flake.nix + direnv)."
echo " dev track - Remove assume-unchanged flag from flake files."
echo " dev untrack - Mark flake files as assume-unchanged in a directory."
echo ""
echo " help - Show this help message."
echo ""
print_help() {
echo "NixOS CLI Utility -- version 2.1.3"
echo ""
echo "Usage: ncli [command]"
echo ""
echo "System Commands:"
echo " rebuild - Rebuild the NixOS system configuration."
echo " update - Update the flake and rebuild the system."
echo ""
echo "Maintenance Commands:"
echo " cleanup - Clean up old system generations. Can specify a number to keep."
echo " diag - Create a system diagnostic report (saves to ~/diag.txt)."
echo " list-gens - List user and system generations."
echo " trim - Trim filesystems to improve SSD performance."
echo ""
echo "Git Commands:"
echo " commit [msg] - Add all changes and commit with message."
echo " push - Push changes to origin."
echo " pull - Pull latest changes from origin."
echo " status - Show git status."
echo ""
echo "Development Commands:"
echo " dev - Initialize a Nix development environment (flake.nix + direnv)."
echo " dev track - Remove assume-unchanged flag from flake files."
echo " dev untrack - Mark flake files as assume-unchanged in a directory."
echo ""
echo " help - Show this help message."
echo ""
}
'';
in
pkgs.writeShellScriptBin "ncli" ''
@ -70,6 +72,7 @@ in
${lib.print_success}
${lib.print_error}
${lib.print_info}
${print_help}
# --- Main Logic ---
if [ "$#" -eq 0 ]; then
@ -122,7 +125,7 @@ in
${dev.dev_case}
;;
help)
${print_help}
print_help
;;
*)
echo "Error: Invalid command '$1'" >&2