- Download Minimal NixOS to
$ISO_PATH
- insert drive
lsblk
-> find out drive name (e.g./dev/sdb
)$DRIVE
- run (as root)
dd bs=4M if=$ISO_PATH of=$DRIVE conv=fdatasync status=progress && sync
- Enable secure boot
- Install Windows 11. Windows 11 now lets you choose size of primary partition during install, I recommend 200GB on a 4TB drive, but lower (100GB) should be fine.
- Install all updates under Windows while we're at it.
- Optional: Create a windows recovery USB Drive (Search for "Create Recovery Drive") [Fair warning: This is slooooooooow].
- Disable secure boot
- Clear secure boot keys
- Install NixOS as below, creating a new EFI boot partition separate from the windows one.
Fantastic Inspiration: https://www.youtube.com/watch?v=YPKwkWtK7l0 NixOS Guide on using Btrfs: https://nixos.wiki/wiki/Btrfs
Note: Disko doesn't support dual-booting just yet, so we're still doing it imperatively.
-
Boot into Minimal NixOS
-
sudo su
-
nix-shell -p neovim
-
lsblk
-> find out disk name (e.g./dev/nvme0n1
)$DISK
-
export DISK=/dev/nvme0n1
-
gdisk $DISK
p
(print)d
(delete)n
(new)- number=(1|5), begin=default, end=
+2G
, hex code=ef00
($BOOT
from now on, or/dev/nvme0n1p5
etc) - number=(2|6), begin=default, end=default, hex code=
8e00
($MAIN
from now on)
- number=(1|5), begin=default, end=
w
(write)
-
export BOOT=/dev/nvme0n1p5
-
export MAIN=/dev/nvme0n1p6
-
LVM on LUKS (BTRFS setup inspired by https://github.com/nix-community/disko/blob/master/example/luks-btrfs-subvolumes.nix)
cryptsetup luksFormat $MAIN
cryptsetup luksOpen $MAIN nixos-enc
pvcreate /dev/mapper/nixos-enc
vgcreate nixos-vg /dev/mapper/nixos-enc
lvcreate --size <swap size, e.g. 8G, usually pick 2xRAM for hibernation if space doesn't matter> --name swap nixos-vg
lvcreate --size 100%FREE --name root nixos-vg
-
Create Boot and Main FS
mkfs.vfat -n boot $BOOT
nix-shell -p btrfs-progs
mkfs.btrfs --label nixos /dev/nixos-vg/root
mkdir -p /mnt
mount /dev/nixos-vg/root /mnt
btrfs subvolume create /mnt/root
btrfs subvolume create /mnt/nix
btrfs subvolume create /mnt/persist
btrfs subvolume create /mnt/home
umount /mnt
-
Create and Mount Swap
mkswap --label swap /dev/nixos-vg/swap
swapon /dev/nixos-vg/swap
-
Mount Everything
mount -o compress=zstd,noatime,subvol=root /dev/nixos-vg/root /mnt
mkdir /mnt/{home,nix,persist}
mount -o compress=zstd,noatime,subvol=nix /dev/nixos-vg/root /mnt/nix
mount -o compress=zstd,noatime,subvol=persist /dev/nixos-vg/root /mnt/persist
mount -o compress=zstd,noatime,subvol=home /dev/nixos-vg/root /mnt/home
mkdir /mnt/boot
mount $BOOT /mnt/boot
-
Generate config
nixos-generate-config --root /mnt
-
Add Btrfs mount options to hardware-config (since
nixos-generate-config
doesn't do that automatically yet):nvim /mnt/etc/nixos/hardware-configuration.nix
fileSystems = { "/".options = [ "compress=zstd" "noatime" ]; ... };
-
Add minimum required stuff to config (
nvim /mnt/etc/nixos/configuration.nix
)boot.initrd.luks.devices = { root = { device = "$MAIN"; preLVM = true; }; }; # If not dual-booting with GRUB boot.loader.systemd-boot.enable = true; networking.networkmanager.enable = true; users.users.farlion = { extraGroups = ["wheel" "video" "audio" "disk" "networkmanager"]; isNormalUser = true; };
-
Nixos go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
nixos-install
-
reboot
- change your name to
farlion
because it's hardcoded in the configurations passwd farlion
and thensu farlion
nix-shell -p git neovim
export NIXOS_TMP_CONFIG=/home/farlion/nixos-tmp-config
git clone https://github.com/workflow/nixos-config.git $NIXOS_TMP_CONFIG
cd $NIXOS_TMP_CONFIG
- Make a new
machines/<new_hostname>
from the base settings at/etc/nixos/{hardware-}configuration
mkdir machines/<new_hostname>
cp /etc/nixos/hardware-configuration.nix machines/<new_hostname>/hardware-scan.nix
cp /etc/nixos/configuration.nix machines/<new_hostname>/system.nix
- Remove imports from
machines/<new_hostname>/hardware-scan.nix
andmachines/<new_hostname>/system.nix
- Set correct DHCP config in
machines/<new_hostname>/hardware-scan.nix
- Update
networking.hostname
inmachines/<new_hostname>/system.nix
- Check from other similar machines and copy any further settings that may be needed
- Update
flake.nix
with new machine nix-shell -p cachix
sudo nvim /etc/nixos/configuration.nix
- Add
nix.settings.trusted-users = ["root" "farlion"]
sudo nixos-rebuild switch
cachix use workflow-nixos-config
git add machines/<new_hostname>
(for flakes to pick up the changes)sudo nixos-rebuild boot --flake .#<new hostname> --override-input secrets nixpkgs
- Reboot
- Go through any immediately needed adaptations : )
- Push any local
$NIXOS_TMP_CONFIG
config changes to github- Temporarily disable automatic git signing in
home/git.nix
- Create new SSH key:
ssh-keygen -t ed25519 -C "farlion@<new_hostname>"
, naming itgithub
- Add SSH key to github
GIT_SSH_COOMAND="ssh -i /home/farlion/.ssh/github" git push
- Temporarily disable automatic git signing in
trash-put $NIXOS_TMP_CONFIG
ln -s ~/code/nixos-config ~/nixos-config
- Go through secret setup instructions
- Customize
~/code/nixos-config/machines/<new_hostname>/{system.nix&&hardware-scan.nix}
while cleaning them up, taking inspiration from similar machines - Change
root
passwd nh os boot
- Reboot
- Update firmware:
fwupdmgr regresh && fwupdmgr get-updates
- Add <new_hostname> to CI build