NixOS on Hetzner cloud in 2022-01

Whatever information I find about how to install NixOS on Hetzner cloud, gives instructions or describe features which do not seem to match what I can find on Hetzner cloud today.

For example NixOS in the Hetzner Cloud states

There is another option in the cloud console: “ISO IMAGES”:

I cannot find such an option in the console.

Or, nixos-install-scripts/ at e815d85edf1bd02063833f833d8878ec952fb1ae · nix-community/nixos-install-scripts · GitHub instructs:

Mount the above mentioned ISO image from the Hetzner Cloud GUI […]

I cannot find any such possibility in any GUI.

Can you suggest how to install NixOS on Hetzner Cloud today?

The instructions in the nixos-infect README appear to work like a charm.

Did you create the server yet? I also remember looking into the instructions before diving in, but it appeared you need to create the server first. It is not possible to create a fresh server with the ISO image.

Just create the server, and go to its settings:

1 Like

Exactly. I’ve discovered this in the meantime (but haven’t had time to report back, which I was planning to do, with pretty much exactly the same image you posted).

In addition to what you already said, there’s one more pitfall before you get that far. When you create the server, you are confronted with a bar like this:

If you click on the three dots on the right, you get the pop-up menu show on the image, which doesn’t give access to image selection. In order to get to the screen shown in your image, you have to click on the bar but ANYWHERE EXCEPT THOSE THREE DOTS.

It took me a good number of iterations before I accidentally discovered this feature.

1 Like

But, unless I’m missing something, you shouldn’t bother. The following seems to work very smoothly for me.

  1. Make sure that you have uploaded an SSH key, and selected it before creating the server.
  2. Pick just about any of the OSes they propose. (I’ve tried it with both latest Ubuntu and latest Debian.)
  3. Once the server is up:
    ssh root@$HOST 'curl | NIX_CHANNEL=nixos-21.11 bash -x'
  4. About 2 minutes later your server should have rebooted into NixOS 21.11.


  1. Make sure to replace $HOST with the IP address of your server, in step 3 above.
  2. You’ll have to deal with SSH fingerprints for the server twice.

This is actually exactly what went through my mind when I tried to describe where to find the option. I couldn’t really think of it and actually was surprised the three dots didn’t show a general ‘Settings’ item or similar.

nixos-infect was new to me, but I looked at it yesterday and think it’s awesome. My only caveat is that I am not an expert at shell scripting and deciphering that script. I don’t quite understand everything going on in the script, while the nixos-install-scripts script is much easier to understand.

Anyhow, the most important part in the nixos-infect script is probably the networking and SSH key.

I just wanted to say that I booted the nixos iso and installed by hand in a Hetzner VPS a week ago and everything went fine.

The only thing to watch out for is not removing the tiny partition Hetzner adds at the end of the disk. Removing it bricked the VPS and left me with a non-bootable VM and I had to start over.

1 Like

Yes, it seems to work quite well. Maybe I just haven’t played with it enough, but there are two things that seem easier about the nixos-infect approach:

  1. It automatically takes care of propagating my ssh key into the NixOS system.
  2. It automatically takes care of hardware-configuration.nix.

With the ISO approach, I seem to have to do these by hand.

The nixos-infect instructions suggest that there is a more direct way of getting it to work than I have been doing. You should be able to paste the nixos-infect magic incantation into the Hetzner user data box, rather than SSHing in and executing the incantation from inside the machine by hand. When I paste into the user data box, it does leave the log in the specified location, suggesting that the script did run, but it still leaves me in the original OS.


I know it is a old post but I have a problem.
I installed NixOS via nixos-infect script and everything worked fine.
After reboot I am not possible to login at the server with my old password.

What is the problem here?

As stated here:

The root user will not have a password when nixos-infect runs to completion. To enable root login, you must have an SSH key configured.

I already had deploy an ssh key. I create a new one and now it works fine. Thanks for the idea where I could start.