Last active
January 25, 2021 07:38
-
-
Save crertel/adc8dd24e21ea168b6e1fa6a08e3c593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Hacky script hacked together from the NixOS wiki, because NixOS doesn't actually sort out partitionting apparently. | |
set -euo pipefail | |
############### | |
# Setup partitions | |
parted /dev/sda -- mklabel gpt | |
SWAP_SIZE="$(grep MemTotal < /proc/meminfo | awk '{printf("%d\n"), $2/ (1024*1024)}')" | |
parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB | |
parted /dev/sda -- set 1 esp on | |
parted /dev/sda -- mkpart primary 512MiB -"$SWAP_SIZE"GiB | |
parted /dev/sda -- mkpart primary linux-swap -"$SWAP_SIZE"GiB 100% | |
################# | |
# format partitions | |
mkfs.fat -F 32 -n boot /dev/sda1 | |
mkfs.ext4 -L nixos /dev/sda2 | |
mkswap -L swap /dev/sda3 | |
###################### | |
# setup mmounts | |
# Mount the target file system on which NixOS should be installed on /mnt, e.g. | |
mount /dev/disk/by-label/nixos /mnt | |
mkdir -p /mnt/boot | |
mount /dev/disk/by-label/boot /mnt/boot | |
swapon /dev/sda3 | |
nixos-generate-config --root /mnt | |
#TODO: automunge configuration.nix | |
############################# | |
# finish install | |
# nixos-install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment