1.3 Deploy NixOS to any cloud server with nixos-anywhere
Lesson 3 of 3 · 14:06
About this lesson
Your hoster does not offer a NixOS image. Almost none of them do. That turns out not to matter: this demo rents the cheapest virtual machine at Hetzner, boots the Ubuntu image it insists on, and a few minutes later the machine is running a NixOS configuration from a flake, partitioned and formatted exactly as declared. Then it gets a web server, without anybody logging in to install one.
In this video
- Renting a plain cloud VM with no NixOS option, and the small detour around a boot restriction that stock images like to have
- Declaring disks with
disko: partitions, filesystems and mount points as configuration, instead of a checklist you follow once and forget - The single
nix runcommand that takes over a running foreign system and leaves NixOS in its place - What scrolls over the console during the takeover, and why no NixOS installer image is ever involved
- Life after the first deployment: adding a web service with
nixos-rebuild switch --target-host, and then taking SSH off the server on purpose
After this lesson
You can put NixOS on anything that boots Linux and answers SSH, cloud VM or bare metal in an office. You also know why a declarative deployment lets you ship a server that nobody, including you, can log into.
Links:
- Example repository from this video: https://github.com/nixcademy/nixos-anywhere-example
- https://github.com/nix-community/nixos-anywhere