nixos-installer/modules/hardware/hetzner-vps.nix.md
Niklas Gollenstede a4ae2ab551 upgrade to 22.11, add extlinux & hetzner-vps:
- disable wip.fs.disks.devices.*.gptOffset (patch broken with 22.11),
- add wip.bootloader.extlinux,
- add wip.hardware.hetzner-vps profile,
- fix wip.services.dropbear.socketActivation,
2022-12-28 16:43:16 +01:00

1.7 KiB

/*

Hetzner Cloud VPS Base Config

This is "device" type specific configuration for Hetzner's cloud VPS VMs.

Installation / Testing

Hetzner Cloud unfortunately doesn't let one directly upload complete images to be deployed on a new server. Since the VPSes are Qemu VMs, installed images can be tested locally in qemu:

 nix run '.#<hostname>' -- sudo run-qemu $image

Once the system works locally, one can (for example) create a new server instance, boot it into rescue mode, and:

cat $image | zstd | ssh $newServerIP 'zstdcat >/dev/sda && sync'

If the image is very large, even if it is mostly empty and with compression, this can take quite a while. Declaring a smaller image size and expanding it on boot may be a workaround, but (since it depends on the disk partitioning and filesystems used) is out of scope here.

Implementation

#*/# end of MarkDown, beginning of NixOS module:
dirname: inputs: args@{ config, pkgs, lib, ... }: let inherit (inputs.self) lib; in let
    prefix = inputs.config.prefix;
    cfg = config.${prefix}.hardware.hetzner-vps;
in {

    options.${prefix} = { hardware.hetzner-vps = {
        enable = lib.mkEnableOption "the core hardware configuration for Hetzner VPS (virtual) hardware";
    }; };

    config = lib.mkIf cfg.enable ({

        ${prefix}.bootloader.extlinux.enable = true;

        networking.interfaces.eth0.useDHCP = true;
        networking.interfaces.eth0.ipv6.routes = [ { address = "::"; prefixLength = 0; via = "fe80::1"; } ];
        networking.timeServers = [ "ntp1.hetzner.de" "ntp2.hetzner.com" "ntp3.hetzner.net" ]; # overwrite NTP

        profiles.qemu-guest.enable = true;

    });
}