Install NixOS on Hetzner Online
This article is about installing NixOS on Hetzner Online, which provides dedicated bare-metal servers. This is not to be confused by Hetzner cloud, that provides VMs. There are three ways at the time to install NixOS on Hetzner
- From Hetzner's rescue image one can boot into the nixos installer using a custom kexec image that is configured with the fixed IP provied by Hetzner and also contain your ssh key. Tip: The kexec tarball as generated by nixos-generators can remain put into the /boot partition for future use.
- Hetzner also provides an interface to upload your own ISO-images. Also here you may want to build your own iso-image, which has openssh with ssh keys due the lack of a remote console.
- An easier method to install NixOS on Hetzner, is to use the existing integration into NixOps.
Network configuration
From Hetzner's [ https://accounts.hetzner.com/login web interface], one can obtain both ipv4/ipv6 addresses and gateways. Hetzner does not operate dhcp servers, so you need to assign those statically. In this example we use networkd to configure the interface. The same configuration can be used for both the kexec image and the final server.
{ ... }: {
networking.dhcpcd.enable = false;
systemd.network.enable = true;
systemd.network = {
enable = true;
networks."eth0".extraConfig = ''
[Match]
Name = eth0
[Network]
# Add your own assigned Ips/gateways here!
Address = 95.216.111.111/26
Gateway = 95.216.111.1
Address = 2a01:4f9:ffff::1/64
# this should be always fe80::1
Gateway = fe80::1
'';
};
}