#!/bin/bash
set -o errexit

source "$(dirname "$0")/lib.sh"

set -o xtrace

node="$1"

deployment_target_host="$(colmena_eval_string -E "{nodes, ...}: nodes.$node.config.deployment.targetHost")"

ssh -l root -p 22 "$deployment_target_host" nixos-generate-config --show-hardware-config > "hosts/$node/hardware.nix"

echo "Done! But you might need to remove filesystems that have already been configured elsewhere."