feat(zshrc): nor use nh if available

Signed-off-by: Dict Xiong <me@dxng.cn>
This commit is contained in:
Dict Xiong 2026-08-22 01:56:06 +08:00
parent 913032b59d
commit e88d6a4621
No known key found for this signature in database
GPG Key ID: 9D30CC51E95EA056

View File

@ -149,7 +149,14 @@ bnd() {
} }
nor() { nor() {
test -n "$1" || { echo fatal: no verb given; return 1; } test -n "$1" || { echo fatal: no verb given; return 1; }
nixos-rebuild "$1" --flake .${2:+#}$2 local verb="$1"
local flake=".${2:+#$2}"
if command -v nh >/dev/null 2>&1 && [[ "$verb" != dry-build && "$verb" != dry-activate ]]; then
nh os "$verb" --bypass-root-check "$flake"
else
nixos-rebuild "$verb" --flake "$flake"
fi
} }
alias 'nors'='nor switch' alias 'nors'='nor switch'
alias 'norbt'='nor boot' alias 'norbt'='nor boot'