Install NIXOS in an non-disk ordinary dir?

I’m preparing the root fs for a diskless system. My plan is to run

sudo nixos-install --root=/srv/tftproot/rootfs

where /srv/tftproot/rootfs is not a physical partition but an ordinary directory.

The installer finishes most of the work, but in the final steps of installing the bootloader, it finds that this /srv/tftproot/rootfs/boot is apparently not an ESP partition and refused to continue.

Is there a way to persuade the installer to ignore this and generate grub files including the core.efi, which I will use to perform the pxe booting?


Rather than using nixos-install for this, you probably should create a disk image, and dd it straight onto whatever this system will be booting from. exists for this purpose; it can prepare disk images for all kinds of deployment scenarios. I don’t know your exact use case, but you probably want the raw-efi one.

@astrojhgu, are you trying to create a net-based boot environment or something else?

Have you explored the nixos-install options --no-bootloader and --keep-going?

The EFI partition should not be necessary for network boot. nixos needs only /nix/store/ and /etc/nixos to boot. Although some loader must know where to find the kernel and to start nixos configuration.

Creating the netboot media is described in the NixOS manual section Booting from the netboot media.

My nixos boot uses a mostly-empty root fs based on Erase Your Darlings by Graham Christensen. I’d use tmpfs if I were not running zfs for other partitions. Also, Graham’s article NixOS on the Framework has good info about customizing the install media.