diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/burn-nixos.sh | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/scripts/burn-nixos.sh b/scripts/burn-nixos.sh index 7518c1e..43903d7 100755 --- a/scripts/burn-nixos.sh +++ b/scripts/burn-nixos.sh @@ -1,10 +1,37 @@ #!/usr/bin/env bash set -Eeuo pipefail -NIXOS_URL="$1" -USB_STICK="$2" +usage() { + red "Missing argument $1." + cat <<EOF +Usage: + burn-nixos.sh <NIXOS_URL> <USB_STICK> + + Arguments: + NIXOS_URL Download URL for NixOS ISO to be installed. Can be found at https://nixos.org/nixos/download.html + USB_STICK File descriptor of USB stick where to burn the ISO into. Use lsblk or similar tools to get it's name. + +Examples: + Download NixOS 19.03 x86_64 and burn it into stick on /dev/sdb: + NIXOS_URL='https://releases.nixos.org/nixos/19.03/nixos-19.03.172764.50d5d73e22b/nixos-minimal-19.03.172764.50d5d73e22b-x86_64-linux.iso' + burn-nixos.sh "\$NIXOS_URL" /dev/sdb +EOF +} + +NIXOS_URL="${1:-}" +USB_STICK="${2:-}" ISO_PATH='/tmp/nixos.iso' +[[ -z "${NIXOS_URL}" ]] && { + usage 'NIXOS_URL' + exit 2 +} + +[[ -z "${USB_STICK}" ]] && { + usage 'USB_STICK' + exit 2 +} + yellow "Downloading NixOS ISO..." wget -O "${ISO_PATH}" "${NIXOS_URL}" wget -O "${ISO_PATH}.sha256" "${NIXOS_URL}.sha256" @@ -16,6 +43,6 @@ 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}" +blue "$(du -hs /tmp/nixos.iso)" sudo dd if="${ISO_PATH}" of="${USB_STICK}" status=progress green "Done. You can remove the USB stick ${USB_STICK} with no unmounting required." |