#cloud-config # First boot of the Debian image: convert it to NixOS in place with # nixos-infect, then reboot. The result is a bare NixOS that keeps the # image's partitions and the SSH host keys, with root's authorized_keys # taken from the server's ssh_keys. Everything else comes from the flake: # # nixos-rebuild switch --flake ../nixos#${hostname} --target-host root@ # # Log: /var/log/nixos-infect.log (after the reboot under /old-root). hostname: ${hostname} fqdn: ${hostname}.${domain} manage_etc_hosts: true ssh_deletekeys: false write_files: # Corrections to what nixos-infect generates, for this bootstrap # generation only: the takeover of the old root (NIXOS_LUSTRATE) exists # only in the scripted initrd; without an interface the IPv4 default # route is never added (the gateway is not on the /32's link); and the # private network gets an address but no route. - path: /etc/nixos/bootstrap.nix content: | { lib, ... }: { boot.initrd.systemd.enable = false; networking.defaultGateway = lib.mkForce { address = "172.31.1.1"; interface = "eth0"; }; networking.interfaces.enp7s0.ipv4.routes = [ { address = "${private_gateway}"; prefixLength = 32; } { address = "${private_net}"; prefixLength = ${private_prefix}; via = "${private_gateway}"; } ]; } runcmd: # Debian keeps /tmp in RAM; nixos-infect puts its swap file there - >- umount -l /tmp; curl -fsSL -o /root/nixos-infect https://raw.githubusercontent.com/elitak/nixos-infect/${infect_rev}/nixos-infect && echo "${infect_sha256} /root/nixos-infect" | sha256sum -c && PROVIDER=hetznercloud NIX_CHANNEL=${nix_channel} NIXOS_IMPORT=./bootstrap.nix bash -x /root/nixos-infect > /var/log/nixos-infect.log 2>&1