From 29415aa88a423cc24ce3358a286fef34a3541c36 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 20 Mar 2025 03:39:44 +0000 Subject: [PATCH] scripts/deploy: allow --deriv to be either a .drv or a store path --- scripts/deploy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/deploy b/scripts/deploy index ddbefdab6..e03dabc1b 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -19,7 +19,7 @@ usage() { echo "- --variant light|min|''|all (default: '')" echo "- --wireguard always|never|opportunistic: deploy over wireguard" echo "- --ip
: 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 "common idioms:" echo "- deploy all: deploy all hosts, sequentially" @@ -197,14 +197,19 @@ deployOneHost() { local timeout=$(timeoutFor "$variant") + # storePath is allowed to be either a realized derivation, + # or the path to a .drv file itself local myStorePath="$storePath" if [ -z "$myStorePath" ]; then # `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") + myStorePath=$(nix eval --raw -f . "hosts.$host$variant.toplevel.drvPath") + fi + + if [[ "$myStorePath" == *.drv ]]; then info "building $host$variant ($drvPath)" - myStorePath=$(destructive nix-store --realize "$drvPath" "${nixArgs[@]}") + myStorePath=$(destructive nix-store --realize "$myStorePath" "${nixArgs[@]}") if [ -z "$myStorePath" ]; then return 1 fi