Skip to content

Instantly share code, notes, and snippets.

@grahamc
Created December 11, 2016 17:07
Show Gist options
  • Save grahamc/ae0b4a470cbba9a99dca572e7a9f9e38 to your computer and use it in GitHub Desktop.
Save grahamc/ae0b4a470cbba9a99dca572e7a9f9e38 to your computer and use it in GitHub Desktop.
#!/bin/sh
partition_instructions() {
# Delete partition 2
echo "d"
echo "2"
# Delete partition 3
echo "d"
echo "3"
# Create partition 2, using whole disk
echo "n"
echo "2"
echo ""
echo ""
echo "w"
}
partition() {
partition_instructions | fdisk /dev/sda
}
format() {
mkfs.ext4 -L nixos /dev/sda2
}
prepare_disks() {
partition
format
mount /dev/disk/by-label/nixos /mnt
}
extracfg() {
cat <<EOF
{
boot.loader.grub.device = "/dev/sda";
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDa8JEOIubMB6khJYaY2q7fpco+q5RCo5HHwdUrngR4kGCXvdeou0tNldMrR0mshIDBJ4VoI0rTFUe3Sb8W+7iknxHSsY6+7fzQ2DvW7JYmtprEJrlOheqKWzjtLgR1hERDugM1LvFGUUpUj5mZpC2yzJnOuc/jlZ1KWjcK44YyJveqxo128Kv3Xqiz85Bt+nAD69cDs8LzOzvH6YI7RcPmzo04h01eJqcGY3lbOmbfJFvJyB8RhJx7phIALmo3BWITKcc00Hyw52tu86WzMPQuSEn5e9Fel6SL/sdLpxT4V9e8v64TrsNPQrGEw+C2MRYHLE5gqKDLMy/ZK8dA5TMF gchristensen@Lrr.local" ];
}
EOF
}
partition
nixos-generate-config --root /mnt
sed -i "s#./hardware-configuration.nix#./hardware-configuration.nix ./extra.nix#" /mnt/etc/nixos/configuration.nix
extracfg > /mnt/etc/nixos/extra.nix
nixos-install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment