First you will need to build a NixOS kexec tarball. To do this follow the steps outlined below:
gitclonehttps://github.com/cleverca22/nix-tests.git
cdnix-tests/kexec/
# Edit configuration.nix according to your needs. An example can be found below:
nix-build'<nixpkgs/nixos>'-Aconfig.system.build.kexec_tarball-Inixos-config=./configuration.nix-Q-j4
local (Scaleway instance) build
# apt-get update# apt-get install -y git# curl https://nixos.org/nix/install | sh# source ~/.nix-profile/etc/profile.d/nix.sh# git clone https://github.com/cleverca22/nix-tests.git# cd nix-tests/kexec/# vim configuration.nix
remove autoreboot.nix, comment out boot.supportedFilesystems = [ "zfs" ]; (as in the sample config below)
# nix-build '<nixpkgs/nixos>' -A config.system.build.kexec_tarball -I nixos-config=./configuration.nix -Q -j 4# cp result/tarball/nixos-system-x86_64-linux.tar.xz /nixos.tar.xz# cd /# tar -xf nixos.tar.xz# ./kexec_nixos
continue in browser shell.
Example configuration.nix
(removed autoreboot.nix from imports, added SSH key)
# new cmd: nix-build '<nixpkgs/nixos>' -A config.system.build.kexec_tarball -I nixos-config=./configuration.nix -Q -j 4{ lib, pkgs, config,...}:with lib;{imports=[<nixpkgs/nixos/modules/installer/netboot/netboot-minimal.nix>./kexec.nix./justdoit.nix];#boot.supportedFilesystems = [ "zfs" ];
boot.loader.grub.enable=false;
boot.kernelParams=["console=ttyS0,115200"# allows certain forms of remote access, if the hardware is setup right"panic=30""boot.panic_on_fail"# reboot the machine upon fatal boot issues];
systemd.services.sshd.wantedBy= mkForce ["multi-user.target"];
networking.hostName="kexec";# example way to embed an ssh pubkey into the tar
users.users.root.openssh.authorizedKeys.keys=["ssh-rsa AAAAB3.... Your-SSH-key"];}
Create Scaleway Instance
If you know the Scaleway API you can do equivalent steps via API instead of using the webinterface.
Open Scaleway "Create a server" page
Enter name
Select region
Select server type
This will only work for the V and X types of servers (e.g. VC1M or X64-15GB)
Select "Debian Sid" from the distributions tab
Note: At the time of writing of this guide the Ubuntu Xenial did not have a kexec enabled kernel and will therefore not work!
Create server
Wait until server has been provisioned and is done booting
The status of the system can be checked on by looking at the console in the webinterface
Start NixOS kexec System
Copy the prepared NixOS kexec tarball to the server