Leave symlink to latest nix-deploy'ed version

This will keep gc root on the linked derivation and prevent
nix-collect-garbage from removing it.
This commit is contained in:
2026-05-26 16:59:26 +00:00
parent 2c380eaf10
commit 2e02f82ae2

View File

@@ -125,7 +125,22 @@ nix-deploy() {
cmd=(nixos-rebuild)
command -v nixos-rebuild >/dev/null 2>&1 || cmd=(nix run "nixpkgs#nixos-rebuild" --)
"${cmd[@]}" "$action" --flake ".#$config" --target-host "$target" --sudo "$@" |& nom
nix build ".#nixosConfigurations.$config.config.system.build.toplevel" \
--out-link "result.$config" |& nom
local build_status=$pipestatus[1]
if (( build_status != 0 )); then
return $build_status
fi
if [[ "$action" != "build" ]]; then
# Bypass nixos-rebuild self-update check which errors in
# flake-only setups when --store-path is used.
_NIXOS_REBUILD_REEXEC=1 "${cmd[@]}" "$action" \
--store-path "$(readlink -f "result.$config")" \
--target-host "$target" \
--sudo \
"$@"
fi
}
myip() {