/*
This is "device" type specific configuration for Hetzner's cloud VPS VMs.
Since the VPSes are qemu VMs, the systems can quite accurately be tested locally in qemu:
nix run '.#<hostname>' -- run-qemu --install
Once the system works locally, a fresh installation can be deployed to a new VPS:
HCLOUD_TOKEN=... nix run '.#<hostname>' -- deploy-system-to-hetzner-vps -- --name='<server-name>' --type='<server-type>'
nix run '.#<hostname>' -- --help # for more details
Or deploy an existing image using deploy-image-to-hetzner-vps
. The HCLOUD_TOKEN
needs to be created in the cloud console, is specific to the cloud project, has to have write access, and can be revoked after the installation.
Alternatively, manually create a new server instance, boot it into rescue mode, and copy the installed image to it:
cat $image | zstd | ssh $newServerIP 'zstdcat >/dev/sda && sync'
If the system image is very large, even if it is mostly empty and with compression, the copy process 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.
#*/# end of MarkDown, beginning of NixOS module:
dirname: inputs: args@{ config, pkgs, lib, ... }: let lib = inputs.self.lib.__internal__; in let
prefix = inputs.config.prefix; inherit (inputs.installer.inputs.config.rename) installer;
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 ({
boot.loader.extlinux.enable = pkgs.system == "x86_64-linux";
boot.loader.systemd-boot.enable = pkgs.system == "aarch64-linux";
${installer}.scripts.hetzner-deploy.path = ./hetzner-deploy-vps.sh;
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" ]; # (these should be most accurate)
profiles.qemu-guest.enable = true;
});
}