diff options
author | EuAndreh <eu@euandre.org> | 2019-06-01 21:02:20 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-06-01 21:02:20 -0300 |
commit | eabe67dcbfa17d2571d41d275c8f4aed6ed4831b (patch) | |
tree | cc4e27d9cc2789512df0b5c50c5aa6e45c80b483 /public/nixos | |
parent | Duplicate Nix files from /etc/nixos/* to /mnt/etc/nixos/ (diff) | |
download | dotfiles-eabe67dcbfa17d2571d41d275c8f4aed6ed4831b.tar.gz dotfiles-eabe67dcbfa17d2571d41d275c8f4aed6ed4831b.tar.xz |
Move scripts/burn-nixos.sh -> public/nixos/burn.sh
Diffstat (limited to 'public/nixos')
-rwxr-xr-x[l---------] | public/nixos/burn.sh | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/public/nixos/burn.sh b/public/nixos/burn.sh index 3b029a1..85ce6cd 120000..100755 --- a/public/nixos/burn.sh +++ b/public/nixos/burn.sh @@ -1 +1,48 @@ -../../scripts/burn-nixos.sh
\ No newline at end of file +#!/usr/bin/env bash +set -Eeuo pipefail + +usage() { + red "Missing argument $1.\n" + cat <<EOF +Usage: + burn.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 minimal 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.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 -cO "${ISO_PATH}" "${NIXOS_URL}" +wget -cO "${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" ||: +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." |