···55[Pixiecore](https://github.com/danderson/netboot/tree/main/pixiecore) and
66[nixos-anywhere](https://nix-community.github.io/nixos-anywhere).
7788+Currently, only `x86_64-linux` is supported.
99+810## Usage
9111212+Example command to boot a custom NixOS installer and install the corresponding
1313+NixOS configuration from [`./examples/flake.nix`](./examples/flake.nix) on
1414+multiple bare-metal machines based on the MAC addresses defined in
1515+[`./examples/hosts.json`](./examples/hosts.json).
1616+1017```sh
1111-nixie \
1818+sudo nixie \
1919+ --installer ./examples#nixosConfigurations.installer \
1220 --flake ./examples \
1313- --installer ./examples#installer \
1414- --hosts ./examples/hosts.json
2121+ --hosts ./examples/hosts.json \
2222+ --ssh-key ~/.ssh/id_ed25519
2323+```
2424+2525+TODO add a demo video/asciinema.
2626+2727+Please see the full example in [`./examples`](./examples).
2828+2929+## How it works
3030+3131+TODO refine the diagram after implementation.
3232+3333+```mermaid
3434+sequenceDiagram
3535+ participant Nix
3636+ participant Nixie
3737+ participant Machines@{ "type" : "collections" }
3838+3939+ Nixie->>Nixie: Load hosts.json
4040+4141+ loop For each machine
4242+ Nixie->>Machines: Try checking status
4343+ end
4444+4545+ Nixie->>Nixie: Filter already installed hosts
4646+ Nixie->>Nix: Build installer components<br/>(kernel, initrd, squashfs)
4747+ Nixie->>Nixie: Start server components in goroutines<br/>(DHCP/TFTP/HTTP/API)
4848+4949+ loop For each machine
5050+ Nixie->>Machines: Broadcast Wake-on-LAN magic packet
5151+5252+ activate Machines
5353+5454+ Note over Machines: Power on and start PXE boot
5555+5656+ Machines->>Nixie: UEFI firmware broadcast DHCP request
5757+ Nixie->>Machines: DHCP provide IP (via Proxy DHCP) and next server info
5858+ Machines->>Nixie: Request kernel
5959+ Nixie->>Machines: TFTP send kernel
6060+ Machines->>Nixie: Request initrd
6161+ Nixie->>Machines: TFTP send initrd
6262+6363+ Note over Machines: Boot into NixOS installer
6464+ Note over Machines: SystemD starts nixie-agent service
6565+ Machines->>Nixie: nixie-agent phone home to request install with MAC address
6666+ Nixie->>Nixie: Find flake based on MAC address and get client IP from API request
6767+ Nixie->>Nix: Build NixOS configuration
6868+ Nixie->>Machines: nixos-anywhere format disks via SSH based on disko configuration
6969+ Nixie->>Machines: nixos-anywhere install system closure via SSH
7070+ Nixie->>Machines: nixos-anywhere trigger reboot
7171+7272+ Note over Machines: Reboot after installation completed
7373+7474+ Nixie->>Machines: nixos-anywhere confirms machine rebooted
7575+ deactivate Machines
7676+7777+ activate Machines
7878+7979+ Nixie->>Machines: Check host status
8080+ end
8181+8282+ Note over Nixie: Return when all machines are installed
1583```