Skip to content

Instantly share code, notes, and snippets.

Created May 28, 2020
What would you like to do?
NixOS Installation Init
# Always use the by-id aliases for devices, otherwise ZFS can choke on imports.
export DISK=/dev/disk/by-id/ata-CT500MX500SSD1_1902E1E1E7CD
echo "partitioning disk"
sgdisk --zap-all $DISK
sgdisk -a1 -n2:34:2047 -t2:EF02 $DISK
sgdisk -n3:1M:+512M -t3:EF00 $DISK
sgdisk -n1:0:0 -t1:BF01 $DISK
echo "sleeping..."
sleep 15
echo "done"
echo "creating zpool and mounts"
zpool create -f -O atime=off -O mountpoint=none -o ashift=12 -R /mnt rpool $DISK-part1
zfs create -p -o mountpoint=legacy rpool/local/root
zfs create -p -o mountpoint=legacy rpool/local/nix
zfs create -p -o mountpoint=legacy rpool/local/docker
zfs create -p -o mountpoint=legacy rpool/safe/home
zfs snapshot rpool/local/root@blank
mkdir -p /mnt/boot
mkdir -p /mnt/nix
mkdir -p /mnt/home
mkdir -p /mnt/persist
mkfs.vfat $DISK-part3
mount -t zfs rpool/local/root /mnt
mount $DISK-part3 /mnt/boot
mount -t zfs rpool/local/nix /mnt/nix
mount -t zfs rpool/safe/home /mnt/home
mount -t zfs rpool/local/docker /mnt/var/lib/docker
echo "Generating configuration.nix and hardware-configuration.nix based on the system"
nixos-generate-config --root /mnt
echo "You'll need the following UUID for your boot mount"
cat /mnt/etc/nixos/hardware-configuration.nix | grep uuid
echo "Copying your custom configuration.nix and hardware-configuration.nix to the appropriate location"
cp configuration.nix /mnt/etc/nixos/configuration.nix
cp hardware-configuration.nix /mnt/etc/nixos/hardware-configuration.nix
echo "Adjust hardware configuration and run nixos-install --no-root-passwd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment