feat(zshrc): norbd

Signed-off-by: Dict Xiong <me@dxng.cn>
This commit is contained in:
Dict Xiong
2026-11-18 10:24:00 +08:00
parent 277c124d3b
commit c2abe34bec

18
.zshrc2
View File

@@ -158,6 +158,24 @@ nor() {
nixos-rebuild "$verb" --flake "$flake" nixos-rebuild "$verb" --flake "$flake"
fi fi
} }
norbd() (
local store_path
if command -v nh >/dev/null 2>&1; then
local tmpdir
tmpdir=$(mktemp -d) || return $?
# Keep the new system rooted until nixos-diff exits.
trap 'rm -f -- "$tmpdir/result"; rmdir -- "$tmpdir"' EXIT
nh os build --bypass-root-check --out-link "$tmpdir/result" ".${1:+#$1}" || return $?
store_path=$(readlink -e -- "$tmpdir/result") || return $?
else
local host_name="${1:-$HOST}"
store_path=$(nix --extra-experimental-features 'nix-command flakes' build \
--no-link --print-out-paths ".#nixosConfigurations.\"$host_name\".config.system.build.toplevel") || return $?
fi
nixos-diff "$store_path"
)
alias 'nors'='nor switch' alias 'nors'='nor switch'
alias 'norbt'='nor boot' alias 'norbt'='nor boot'
alias 'nort'='nor test' alias 'nort'='nor test'