Install NixOS on Hetzner Online

From NixOS Wiki
Revision as of 12:45, 14 January 2019 by imported>Mic92 (network configuration snippet)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

  1. 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.
  2. 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.
  3. 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
        IPv6AcceptRA = no
        IPForward = yes
        [DHCP]
        UseDNS = no
      '';
  };
}