scripts/deploy: separate eval and build phases to decrease maximum ram requirements
This commit is contained in:
@@ -154,10 +154,16 @@ deployOneHost() {
|
||||
local host="$1"
|
||||
local variant="$2"
|
||||
|
||||
info "building $host$variant ..."
|
||||
destructive nix-build -A "hosts.$host$variant.toplevel" --out-link "./build/result-$host$variant" "${nixArgs[@]}" || return 1
|
||||
storePath="$(readlink ./build/result-$host$variant)"
|
||||
info "build $host$variant -> $storePath"
|
||||
# `nix-build -A foo` evals and then realizes foo, but it never unloads the memory used to eval foo.
|
||||
# my exprs are heavyweight, we need that memory for building, so do the evals separately from the realizations:
|
||||
info "evaluating $host$variant..."
|
||||
local drvPath=$(nix eval --raw -f . "hosts.$host$variant.toplevel.drvPath")
|
||||
info "building $host$variant ($drvPath)"
|
||||
local storePath=$(destructive nix-store --realize "$drvPath" "${nixArgs[@]}")
|
||||
if [ -z "$storePath" ]; then
|
||||
return 1
|
||||
fi
|
||||
info "built $host$variant -> $storePath"
|
||||
|
||||
# mimic `nixos-rebuild --target-host`, in effect:
|
||||
# - nix-copy-closure ...
|
||||
|
Reference in New Issue
Block a user