From 3a44b124561f544c229c0042cd0b91d055a33409 Mon Sep 17 00:00:00 2001 From: Mark Nipper Date: Thu, 11 Apr 2024 01:37:43 -0700 Subject: Add work VM and redo entire flake layout --- scripts/install-with-disko | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 scripts/install-with-disko (limited to 'scripts/install-with-disko') diff --git a/scripts/install-with-disko b/scripts/install-with-disko new file mode 100755 index 0000000..859a647 --- /dev/null +++ b/scripts/install-with-disko @@ -0,0 +1,68 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i zsh --packages rsync zsh + +setopt ERR_EXIT NO_UNSET PIPE_FAIL +DIR="${0:h}" + +TARGET_HOST="${1:-}" +TARGET_USER="${2:-nipsy}" + +if [[ "${USERNAME}" != "nixos" ]]; then + echo "ERROR! ${0:t} should be run as the nixos user from a NixOS installer." >&2 + exit 1 +fi + +if [[ -z "$TARGET_HOST" ]]; then + echo "ERROR! ${0:t} requires a hostname as the first argument." >&2 + exit 1 +fi + +if [[ ! -e "${DIR}/../hosts/${TARGET_HOST}/disks.nix" ]]; then + echo "ERROR! ${0:t} could not find the required ${DIR}/../hosts/${TARGET_HOST}/disks.nix." >&2 + exit 1 +fi + +# Check if the machine we're provisioning is using an encrypted pool. +# If it does, prompt for the passphrase, and write to a known location. +if grep -q "data.keyfile" "${DIR}/../hosts/${TARGET_HOST}/disks.nix"; then + while true; do + echo -en "\n${TARGET_HOST} uses ZFS encryption. Enter a passphrase to encrypt your pool: " + read -s pass + echo -e '\n' + + if [[ "${#pass}" -lt 8 ]]; then + echo 'ERROR! Passphrase must be at least 8 characters.' >&2 + else + break + fi + done + + echo -n "${pass}" > /tmp/data.keyfile && chmod 00600 /tmp/data.keyfile +fi + + +<