Unattended install via usb stick

I am currently researching how to do an unintended NixOS install via USB stick.
It should re-partition and install a minimal NixOS with just a ssh pub key setup to log into.
All without user interaction.

After searching a bit I came across the following information and repos.

https://nixos.org/manual/nixos/unstable/#sec-installation

nixos-auto-installer seems like what I am after.
nixos-offline-installer would be even cooler - but feels like a cherry on top.

I couldn’t really find an “official” approach yet. Is there one?
Is there any other approach that I should look into?
Or is nixos-auto-installer a good path to follow?

cheers,
Torsten

2 Likes

@tfc and I are currently working on a nix.dev tutorial to deploy a fresh NixOS via SSH with nixos-anywhere and partitioning with disko. The difference to what you’re looking for will be minimal.

I currently only have the relevant code in a private repo, but the idea is that you define a regular installer image, and add a tiny extra script that is launched on login and essentially runs:

${machine.config.system.build.diskoScript}
nixos-install --no-root-password --no-channel-copy --system ${machine.config.system.build.toplevel}
reboot

Conveniently this incorporates the entire store path closure in the image, leading to a fully offline installation.

4 Likes

The auto installer and offline installer both attempt to do the same thing. Please ignore the offline installer, as the auto installer is the newer repository. It does both install automatically and is fully offline-capable.

At Nixcademy, we use it throughout the Nix & NixOS 101 class to prepare training laptops with a standardized NixOS installation.

2 Likes

See also misuzu / nixos-unattended-install-iso · GitLab
You can test it in qemu like this:
nix run -L git+https://gitlab.com/misuzu/nixos-unattended-install-iso

1 Like