I'd like to install NixOS to a flash drive, and have the operating system run entirely on the flash drive. Is it possible to install to a flash drive using NixOps? Or would I even need to? That is, would it be easier or better just to write a script that would do it?
Is it possible (or advisable) to use NixOps to install NixOS to a USB flash drive?
833 views Asked by Jonathan At
1
First let's get this out of the way: if the purpose is just creating a live installer to install NixOS on a system, you should follow the instructions in the NixOS manual.
Assuming you want the drive to be capable of updating itself, you should avoid NixOps. Unlike the
nixos-install
command, NixOps was not designed to copy only the evaluated and built machine to the target machine. It will not copy the Nix-language expressions over to it, so the target machine will not be able to update or modify itself.I see two possible approaches for this. The most straightforward one is to use the
nixos-install
command to install NixOS on the drive like you would install it on an internal drive. To the kernel and every sane BIOS, a USB stick is just another block device to boot from.The other approach is following the manual and changing the
root=
parameter, which may make changes persistent. I have never done it for my installation USB sticks, so I don't know whether that really works.