2023-08-23 11:19:02 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -exo pipefail
|
|
|
|
|
|
|
|
|
|
# Name of the file to write out
|
|
|
|
|
name="${0%.sh}"
|
|
|
|
|
|
|
|
|
|
version="23.05"
|
|
|
|
|
|
|
|
|
|
# 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
|
2023-12-06 08:21:32 -08:00
|
|
|
sha="$(grep -e minimal "${checksums}" | cut -d' ' -f 1)"
|
2023-08-23 11:19:02 -05:00
|
|
|
|
|
|
|
|
# Write out HCL file
|
|
|
|
|
cat << EOF > "${name}"
|
|
|
|
|
distro = "nixos"
|
|
|
|
|
version = "${version}"
|
|
|
|
|
iso = {
|
|
|
|
|
url = "${base}"
|
|
|
|
|
checksum = "${sha}"
|
|
|
|
|
}
|
|
|
|
|
boot_command = [
|
2023-12-30 05:37:32 +00:00
|
|
|
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>",
|
|
|
|
|
"<wait5>",
|
|
|
|
|
"sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}<enter>"
|
2023-08-23 11:19:02 -05:00
|
|
|
]
|
|
|
|
|
http_directory = "distros/nixos/23.05/http/"
|
2023-12-30 05:37:32 +00:00
|
|
|
boot_wait = "60s"
|
2023-08-23 11:19:02 -05:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
rm -r "${tmp}"
|