Install NixOS on a Contabo-VPS

this little guide describes how to bootstrap nix to install nixos on a contabo-vps server:

create /nix and used tempfs, because otherwise the disk is full quickly

mkdir /nix
mount -t tmpfs tmpfs /nix -o size=5g

create nix-build users

groupadd nixbld
for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done

change password of xuser (so we can use sudo later) and switch to it

passwd xuser
su xuser

install nix

bash <(curl -L
. $HOME/.nix-profile/etc/profile.d/
sudo nix-channel --add nixpkgs

setup nixpkgs

sudo -E nix-env -iE "_: with import <nixpkgs/nixos> { configuration = {}; }; with; [ nixos-generate-config nixos-install nixos-enter manual.manpages ]"

clone config repo

git clone
cd nixos

make sure to include this config:

{ config, lib, pkgs, ... }:

  boot.initrd = {
    availableKernelModules = [
      "virtio_pci"  # disk
      "virtio_scsi" # disk
    kernelModules = [

wipe disks and install from scratch

sudo -E ./

then exit xuser and reboot


after rebooting update nix-channels

nix-channel --add nixos
nixos-rebuild switch --upgrade