scripts/deploy: allow --deriv to be either a .drv or a store path
This commit is contained in:
@@ -19,7 +19,7 @@ usage() {
|
|||||||
echo "- --variant light|min|''|all (default: '')"
|
echo "- --variant light|min|''|all (default: '')"
|
||||||
echo "- --wireguard always|never|opportunistic: deploy over wireguard"
|
echo "- --wireguard always|never|opportunistic: deploy over wireguard"
|
||||||
echo "- --ip <address>: deploy to the specific IP address"
|
echo "- --ip <address>: deploy to the specific IP address"
|
||||||
echo "- --deriv /nix/store/...: prebuilt store path to deploy instead of (re-)building the default target"
|
echo "- --deriv /nix/store/...: prebuilt store path (or .drv to realize) to deploy instead of (re-)building the default target"
|
||||||
echo ""
|
echo ""
|
||||||
echo "common idioms:"
|
echo "common idioms:"
|
||||||
echo "- deploy all: deploy all hosts, sequentially"
|
echo "- deploy all: deploy all hosts, sequentially"
|
||||||
@@ -197,14 +197,19 @@ deployOneHost() {
|
|||||||
|
|
||||||
local timeout=$(timeoutFor "$variant")
|
local timeout=$(timeoutFor "$variant")
|
||||||
|
|
||||||
|
# storePath is allowed to be either a realized derivation,
|
||||||
|
# or the path to a .drv file itself
|
||||||
local myStorePath="$storePath"
|
local myStorePath="$storePath"
|
||||||
if [ -z "$myStorePath" ]; then
|
if [ -z "$myStorePath" ]; then
|
||||||
# `nix-build -A foo` evals and then realizes foo, but it never unloads the memory used to eval foo.
|
# `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:
|
# my exprs are heavyweight, we need that memory for building, so do the evals separately from the realizations:
|
||||||
info "evaluating $host$variant..."
|
info "evaluating $host$variant..."
|
||||||
local drvPath=$(nix eval --raw -f . "hosts.$host$variant.toplevel.drvPath")
|
myStorePath=$(nix eval --raw -f . "hosts.$host$variant.toplevel.drvPath")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$myStorePath" == *.drv ]]; then
|
||||||
info "building $host$variant ($drvPath)"
|
info "building $host$variant ($drvPath)"
|
||||||
myStorePath=$(destructive nix-store --realize "$drvPath" "${nixArgs[@]}")
|
myStorePath=$(destructive nix-store --realize "$myStorePath" "${nixArgs[@]}")
|
||||||
if [ -z "$myStorePath" ]; then
|
if [ -z "$myStorePath" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user