Files
vms/distros/nixos/23.11/amd64.pkrvars.hcl.sh
T

42 lines
914 B
Bash
Executable File

#!env bash
set -exo pipefail
# Name of the file to write out
name="${0%.sh}"
version="23.11"
# Base URL
base="https://channels.nixos.org/nixos-${version}/latest-nixos-minimal-x86_64-linux.iso"
# Working directory
tmp="$(mktemp -d)"
checksums="${tmp}/checksums"
# Read the SHA256 sum value
curl -L -o "${checksums}" "${base}.sha256"
until curl -f -L -o "${checksums}" "${base}.sha256"; do
sleep 1
done
sha="$(grep -e minimal "${checksums}" | cut -d' ' -f 1)"
# Write out HCL file
cat << EOF > "${name}"
distro = "nixos"
version = "${version}"
iso = {
url = "${base}"
checksum = "${sha}"
}
boot_command = [
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>",
"<wait>",
"sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}<enter>"
]
http_directory = "distros/nixos/23.11/http/"
boot_wait = "90s"
EOF
rm -r "${tmp}"
rm -f "cache/latest-nixos-minimal-x86_64-linux.iso"