43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
set -x
|
|
|
|
# Requires ssh access to target machine: ssh root@${TARGET}
|
|
TARGET=litten
|
|
TARGET_DOMAIN=brenise.dev
|
|
|
|
FORMAT_DISK ()
|
|
{
|
|
# dd if=/dev/zero count=1 bs=2M of=/dev/nvmen1
|
|
parted /dev/nvme0n1 -- mklabel gpt
|
|
parted /dev/nvme0n1 -- mkpart primary 512MB 100%
|
|
parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB
|
|
parted /dev/nvme0n1 -- set 2 esp on
|
|
mkfs.ext4 -L nixos /dev/nvme0n1p1
|
|
mkfs.fat -F 32 -n boot /dev/nvme0n1p2
|
|
mount /dev/disk/by-label/nixos /mnt
|
|
mkdir -p /mnt/boot
|
|
mount /dev/disk/by-label/boot /mnt/boot
|
|
nixos-generate-config --root /mnt
|
|
}
|
|
|
|
echo "Install NixOS on ${TARGET}? Press enter to continue or ctrl+c to quit."
|
|
read
|
|
|
|
ssh root@${TARGET} "$(typeset -f FORMAT_DISK); FORMAT_DISK"
|
|
|
|
rsync -tv configuration.nix root@${TARGET}:/mnt/etc/nixos/
|
|
|
|
# ssh
|
|
if [ -f ~/.ssh/ansible_root_keys ]; then
|
|
rsync -v ~/.ssh/ansible_root_keys root@${TARGET}:/etc/nixos/ssh/authorized_keys
|
|
else
|
|
rsync -v ~/.ssh/authorized_keys root@${TARGET}:/etc/nixos/ssh/authorized_keys
|
|
fi
|
|
|
|
ssh root@${TARGET} nixos-install
|
|
|
|
# Don't forget to set your passwd
|
|
# To chroot:
|
|
#nixos-enter --root /mnt
|