NixOS on uefi+gpt only systems

Recently I had to migrate my remote NVR living in a rpi4, over to a new whitebox mini pc utilizing the Asrock J5040 motherboard. This NVR consists of Frigate along with a mqtt broker, Home Assistant and inotify for clips/screenshots transfer. This motherboard is referred to as SoC and features the Intel j5040 Gemini Lake series cpu.

Therefore it natively supports only UEFI mode, and any attempt to use legacy bios/CMS boot options (even by disabling fastboot) will prove fruitless and all these hours troubleshooting will be lost in time, like tears in rain :P

Trying to install using the default nixos image will leave you with a black screen, but there’s a solution for that too.

In order to build a uefi & gpt enabled NixOS system you need to use the nixos-generators flake to build a single uefi+gpt NixOS installation image.

The fast way to produce this image:

nix run github:nix-community/nixos-generators -- --help

to list available build options. In this case we need to build a single raw efi image, therefore:

nix run github:nix-community/nixos-generators -- -f raw-efi

Write the resulting image to a usb

sudo dd if=./nixos-raw-efi.img of=/dev/sdX bs=4M status=progress conv=fsync

Boot the target machine and proceed with installation as usual.