Installing VirtualBox NixOS instances - MSF-OCB/NixOS Wiki

This guide explains how to install NixOS on a VirtualBox VM. This approach is mainly used by the field support team to set up remote access to projects when a dedicated laptop is not available.

VirtualBox config


  1. Download the latest VirtualBox version.
  2. Obtain the latest version of our "NixOS Rescue ISO" here

Create a new machine and set:

  1. Name: bevmXXX (increasing numbers, like we do for our NUCs as well)
  2. Machine folder: something like C:\virtualbox_vms
  3. Type: Linux
  4. Version: Other Linux (64-bit)
  5. Memory: 1024 GB
  6. Hard disk: create a 15 GB VDI image, fixed size

Then in the settings:


  1. Enable I/O APIC
  2. Enable EFI
  3. Set 2 CPUs
  4. Enable PAE/NX
  5. Default Paravirtualization interface
  6. Enable nested paging


  1. Set video memory to 9 MB (the minimum)


  1. Delete the existing IDE controller
  2. Add a VirtIO controller
  3. Add the hard disk we created before and the NixOS installation ISO to this controller
  4. Select "solid state" for the disk




Enable the network adapter and set

  1. "Attached to" to "Bridged adapter"
  2. "Name" to the wired ethernet connection (if the laptop is not connected by a cable, then take the wireless connection)
  3. Under advanced, change the adapter type to Paravirtualized network (virtio-net)

Running the NixOS installer


  1. Create a host file in the NixOS-OCB-config repo under hosts. The host file should have the extension .nix and the hostname as filename, everything in small letters. In this file, you will need to set at least the time zone, the host name and the boot method (UEFI if possible). Refer to this list of available timezones to find the right one.
  2. Add an entry for the new host to the file json/tunnels.json in the same repository. You fill in the remote_forward_port with the port corresponding to the machine (6000 + machine number for NUCs, 9000 + machine number for VMs). Since you don't have the public key yet (the installer will generate it), you set it to an empty string for now (two quotes, "") and we will fill in the actual value after the installer generated the key.

When these files are on the master branch on github, connect to the VM using SSH from your own computer by following the steps in this article. From the SSH session, you can then run the installer.

curl -L | sudo bash -s -- -d /dev/<device> -h bevm<num> -r 12 -D

When you launch the script on a new server, the script will create an SSH key pair that will be put in /tmp. The script will then try to authenticate to GitHub using this key, if the authentication does not succeed (and it should not on the first run), then the script will ask you to add the key to GitHub, in the json/tunnels.json file in the NixOS-OCB-config repo. After you added the key to GitHub, and your PR has been merged into master, an action will run which will add this key to the user that we use to authenticate to github, this action takes around 30sec to complete. Once this action completed, the installer will automatically continue with the installation.

Rebooting into the installed system

  1. Turn off the VM
  2. Go into the settings, storage, and remove the NixOS ISO
  3. Restart the machine and it should boot into the installed NixOS system