NixOS
There is no NixOS template in the portal, but you can install NixOS yourself in a few minutes. You order the server with Debian 13 and then run nixos-anywhere from your own computer. The tool replaces Debian with NixOS over SSH, and the server restarts into NixOS with your configuration.
Everything on the server's disk is deleted. Do this on a new server, or copy anything you want to keep first.
What you need
-
A VPS with Debian 13 and at least 2 GB RAM: VPS Medium, VPS Bygg själv or a server in VPS Cloud. The installation runs in the server's memory, and on VPS Small with 1 GB it stops with
Kexec failed. Debian is then left untouched. -
Debian 13 as the OS template. The Ubuntu templates have Secure Boot turned on, and NixOS does not boot with it.
-
Nix on your computer, running Linux, macOS or WSL2 on Windows. On Debian 13 Nix is available as a package:
Log out and in again afterwards. On other systems, install Nix following nixos.org/download.
Turn on flakes, which the installation uses:
Step 1: Get the server's network settings
The NixOS server gets static addresses, so you need to know what Debian was given. Log in to the server with the username from the portal, see Getting started, and run:
Write down:
If the server has a private network, also write down the MAC
address of eth1.
NixOS names the network cards ens18 and ens19 instead of eth0 and eth1. The
configuration below picks the cards by MAC address, so the names do not matter.
Step 2: Write the configuration
Create a directory on your computer, for example nixos-vps, with three files.
flake.nix says which NixOS version you want:
disk-config.nix partitions the disk: an EFI partition and a root partition on the
rest.
configuration.nix is the server itself. Replace the hostname, MAC address,
addresses, gateways, username and SSH key with your own:
The firewall is on from the start and only lets SSH in. Open more ports with, for
example, networking.firewall.allowedTCPPorts = [ 80 443 ];.
If the server has a private network, add a block for the second card with the MAC
address of eth1 and the private address you have chosen. No gateway:
Step 3: Install
Lock the versions and start the installation, with the username and address from the portal:
nixos-anywhere starts a NixOS installer in the server's memory, partitions the disk,
installs and restarts the server. It takes about five minutes. When it says
### Done! ### the server is running NixOS.
flake.lock records exactly which versions were installed. Keep it together with the
other files, preferably in git.
Step 4: Log in
The server has new host keys. Remove the old entry and log in:
Set a password on your account, so that you can log in via Console in the portal if the network should act up:
Change and update the server
The simplest way is to keep the configuration on the server. Copy the directory there once:
When you have changed something in the files, build and switch to the new configuration on the server:
You get security updates by updating the lock file and rebuilding:
NixOS releases a new version in May and November, and each version gets security updates
for about seven months. Move to a new version by changing nixos-26.05 in flake.nix
and running the commands above. Do not change system.stateVersion; it should stay at
the version you installed.
Then Nix only sees files that are added to git. Run git add on new files before you
build.
What works differently
The NixOS server does not have cloud-init, which the portal uses to set up the other operating systems. Therefore:
- SSH keys are changed in
configuration.nix, not with Reset SSH Keys in the portal. - The console password is the one you set with
passwd, not the one shown in the portal. - Extra IPv4 addresses are added to the
addresslist in10-publik, with the netmask/24and no new gateway. - Rebuild in the portal installs the OS template you choose. If you want NixOS again, run step 3 once more.
This works as usual:
- The console in the portal shows the boot menu and the login prompt.
- Bigger disk: the root grows by itself at the next restart.
- Backups and snapshots: the guest agent freezes the file system while they are taken, see Backups and snapshots.