aboutsummaryrefslogtreecommitdiff
path: root/scripts/burn-nixos.sh
blob: 7518c1e437e83af90203e019dd1c8176e52d83af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
set -Eeuo pipefail

NIXOS_URL="$1"
USB_STICK="$2"
ISO_PATH='/tmp/nixos.iso'

yellow "Downloading NixOS ISO..."
wget -O "${ISO_PATH}"     "${NIXOS_URL}"
wget -O "${ISO_PATH}.sha256" "${NIXOS_URL}.sha256"
diff <(sha256sum "${ISO_PATH}" | awk '{print $1}') <(awk '{print $1}' < "${ISO_PATH}.sha256") || {
  red "SHA256 didn't match!"
  exit 1
}
green "Done. SHA256 match."

yellow "Writing ISO image to ${USB_STICK}. We'll need sudo for it..."
umount "${USB_STICK}1" ||:
ls -lahp --color "${ISO_PATH}"
sudo dd if="${ISO_PATH}" of="${USB_STICK}" status=progress
green "Done. You can remove the USB stick ${USB_STICK} with no unmounting required."