blob: 947fd0de0bdf9ff08576eec7673b0b7019387977 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/env bash
set -Eeuo pipefail
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 -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."
|