nixos/zeta/install.txt

196 lines
4.8 KiB
Text

#
# preparation of installer on NixOS machine
# details see https://github.com/nix-community/nixos-apple-silicon/blob/main/docs/uefi-standalone.md
#
# get the Apple Silicon support git
git clone https://github.com/nix-community/nixos-apple-silicon.git
cd nixos-apple-silicon
# build m1n1
nix build .#m1n1 -o m1n1
# build uboot
nix build .#uboot-asahi -o u-boot
# add to nixos-apple-silicon/iso-configuration/installer-configuration.nix
networking.hostId = "cce4e4c1";
boot.supportedFilesystems.zfs = lib.mkForce true;
to have ZFS support
# build installer ISO
nix build .#installer-bootstrap -o installer -j4 -L
# write to USB stick
doas dd if=installer/iso/nixos-25.11.20250528.96ec055-aarch64-linux.iso of=/dev/sda bs=4M conv=fsync
# on the Mac
curl https://alx.sh | sh
# follow instructions on the guide https://github.com/nix-community/nixos-apple-silicon/blob/main/docs/uefi-standalone.md
# boot with installer stick on Mac
I did need to do: (If "mounting `/dev/root` on `/mnt-root/iso` failed: No such file or directory" during boot…)
Some flash drives have quirks. Try a different drive, or use the following steps:
Attempt to start the installer normally
When the boot fails and you are prompted, hit i to start a shell
Unplug your flash drive, plug it into a different port, then wait 30 seconds
Run the command mount -t iso9660 /dev/root /mnt-root/iso
Exit the shell by running exit to continue the boot process
#
# enable ssh for root
#
sudo bash
systemctl start sshd
passwd
# get wlan
iwctl
station wlan0 scan
station wlan0 connect <SSID>
station wlan0 show
exit
# create the system partition
# first: take a peek
sgdisk /dev/nvme0n1 -p
Number Start (sector) End (sector) Size Code Name
1 6 128005 500.0 MiB AF0B iBootSystemContainer
2 128006 121547013 463.2 GiB AF0A Container
3 121547014 122157317 2.3 GiB AF0A
4 122157318 122279429 477.0 MiB EF00
5 242965551 244276259 5.0 GiB AF0C RecoveryOSContainer
# create partition
sgdisk /dev/nvme0n1 -n 0:0 -s
# take a look again
sgdisk /dev/nvme0n1 -p
Number Start (sector) End (sector) Size Code Name
1 6 128005 500.0 MiB AF0B iBootSystemContainer
2 128006 121547013 463.2 GiB AF0A Container
3 121547014 122157317 2.3 GiB AF0A
4 122157318 122279429 477.0 MiB EF00
5 122279430 242965550 460.4 GiB 8300
6 242965551 244276259 5.0 GiB AF0C RecoveryOSContainer
#
# install script below
#
# host name to use
HOST=zeta
# partitions to use
BOOT=/dev/disk/by-id/nvme-APPLE_SSD_AP1024Z_0ba01e0141400628-part4
RAID=/dev/disk/by-id/nvme-APPLE_SSD_AP1024Z_0ba01e0141400628-part5
# take a look at the partitions
lsblk
# ZFS zpool creation with compression and encryption
zpool create \
-o ashift=13 \
-o autotrim=off \
-O acltype=posixacl \
-O atime=off \
-O canmount=off \
-O checksum=blake3 \
-O compression=lz4 \
-O dnodesize=auto \
-O utf8only=on \
-O normalization=none \
-O xattr=sa \
-O mountpoint=none \
-O encryption=on \
-O keylocation=prompt \
-O keyformat=passphrase \
-f zpool $RAID
sleep 5
# take a look at the partitions
lsblk
# show the pool
zpool status
sleep 5
# create all the volumes
zfs create -o recordsize=64K -o mountpoint=legacy zpool/data
zfs create -o recordsize=64K -o mountpoint=legacy zpool/nix
zfs create -o recordsize=64K -o mountpoint=legacy zpool/root
sleep 5
# show the pool
zpool status
sleep 5
# create ZFS snapshot that we'll rollback to on boot
# see https://ryanseipp.com/post/nixos-encrypted-root/
zfs snapshot zpool/root@blank
sleep 5
# prepare install, root
mount -t zfs zpool/root /mnt
# Create directories to mount file systems on
mkdir -p /mnt/{data,nix,boot,root,etc/nixos}
# mount the ESP
mount $BOOT /mnt/boot
# mount volumes
mount -t zfs zpool/data /mnt/data
mount -t zfs zpool/nix /mnt/nix
# bind mount persistent stuff to data
mkdir -p /mnt/data/{root,nixos/$HOST}
mount --bind /mnt/data/root /mnt/root
mount --bind /mnt/data/nixos/$HOST /mnt/etc/nixos
# create fake /data to have the right paths
mkdir -p /data
mount --bind /mnt/data /data
# take a look
mount
# configure
nixos-generate-config --root /mnt
# copy config data from another machine including secrets
doas scp -r /data/nixos root@192.168.13.113:/mnt/data
# add apple silicon support
cp -r /etc/nixos/apple-silicon-support /mnt/etc/nixos/
chmod -R +w /mnt/etc/nixos/
# install
nixos-install --option experimental-features 'nix-command flakes' --no-root-passwd --root /mnt
# unmount all stuff and sync
umount -Rl /data /mnt
zpool export -a
sync
# shutdown once
shutdown now