From 83606e34bb4dcbb174963a9a8b976232da562fba Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Wed, 14 Sep 2022 20:26:41 -0600 Subject: [PATCH] deploy: install now sends store stuff to remote at specific locations --- deploy | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/deploy b/deploy index 16f27f9..909c6f3 100755 --- a/deploy +++ b/deploy @@ -63,24 +63,27 @@ if [ "$1" = "status" ]; then fi if [ "$1" = "install" ]; then + h="$2" host="$(resolveAlias $2)" + dest="${3:-/nix/store}" shift shift - if [ ! -d hosts/${host} ]; then - msg "No config found for $host" + if [ ! -d hosts/${h} ]; then + msg "No config found for $h" exit 1 fi set -eu + set -x mkdir -p .gcroots - out=$(nix build -o .gcroots/${host} --json .#nixosConfigurations.${host}.config.system.build.toplevel | jq -r '.[0].outputs.out') + out=$(nix build -o .gcroots/${h} --json .#nixosConfigurations.${h}.config.system.build.toplevel | jq -r '.[0].outputs.out') - nix copy -s --to "ssh://root@${host}" "$out" - nix copy -s --derivation --to "ssh://root@${host}" "$out" + nix copy -s --to "ssh://root@${host}?remote-store=${dest}" "$out" + nix copy -s --derivation --to "ssh://root@${host}?remote-store=${dest}" "$out" - ${SSH} "root@${host}" nix build --profile /nix/var/nix/profiles/system "$out" - ${SSH} "root@${host}" nix shell -vv "$out" -c switch-to-configuration "$@" + ${SSH} "root@${host}" NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root "$dest" -- nix --extra-experimental-features nix-command build --profile /nix/var/nix/profiles/system "$out" + ${SSH} "root@${host}" NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root "$dest" -- /run/current-system/bin/switch-to-configuration switch exit 0 fi