This pages describes how to install NixOS in a VirtualBox guest.
$ fdisk /dev/sda (create a full partition, don't skip this step, example commands for quick setup: n,p,1,w) $ mkfs.ext4 -j -L nixos /dev/sda1 (idem) $ mount LABEL=nixos /mnt $ mkdir -p /mnt/etc/nixos $ nixos-hardware-scan > /mnt/etc/nixos/configuration.nix (for quick setup overwrite configuration.nix completely with example below) $ nano /mnt/etc/nixos/configuration.nix (add the fileSystems. this is what my final config looks like:) { config, pkgs, ...} :
{
boot.loader.grub.device = "/dev/sda";
services.openssh.enable =true;
services.virtualbox.enable = true;
fileSystems = [
{ mountPoint = "/";
label = "nixos";
}
];
}
Now we're ready to install! $ nixos-install $ reboot Now you got a working nixos system. However, you can't conveniently log in to ssh this way, so you'll need to set up port-forwarding. Doing that is explained on this site, all you have to do is create a script named "vbox-tunnel" that contains the following lines: #!/bin/bash cd /Applications/VirtualBox.app/Contents/MacOS/ ./VBoxManage setextradata "$1" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/$2/Protocol" TCP ./VBoxManage setextradata "$1" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/$2/GuestPort" $3 ./VBoxManage setextradata "$1" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/$2/HostPort" $4 Now execute the script: vbox-tunnel Nix sshtunnel 22 2222 You should be able to log in to Nix now by running Alternative (independent of virtual network card chosen for the guest): VBoxManage modifyvm "Nix" --natpf1 "sshtunnel,tcp,,2222,,22" As before, you are now able to log in to Nix by running |