Set convenience variables: export veid=777 export mountPoint=/mnt Download NixOS minimal install archive. Extract the archive: mkdir /vz/private/$veid tar -xjf nixos-install-archive.tar.bz2 -C /vz/private/$veid Prepare for installation: mount -o bind /vz/private/$veid $mountPoint bash $mountPoint/nix/store/nixos-prepare-install checkout-sources copy-nix Configure NixOS: nano $mountPoint/etc/nixos/configuration.nix This is the minimal working nixos config(don't forget to replace $IP with the IP you're going to assign to the guest):
{pkgs, config, ...}:
{
boot.loader.initScript.enable = true;
# fake root since nixos requires this to be set
fileSystems = [ {
mountPoint = "/";
label = "nixos";
options ="noauto";
} ];
networking = {
defaultGateway = "$IP";
interfaces = [ {
name = "venet0";
ipAddress = "$IP";
} ];
};
}
Install: bash $mountPoint/nix/store/run-in-chroot "/nix/store/nixos-bootstrap --install --no-grub" Configure OpenVZ: vzctl set $veid --applyconfig vps.basic --save vzctl set $veid --ipadd $IP --save Edit /etc/vz/conf/$veid.conf to increase ram and disk space available. NixOs occasionally needs more than 256M of RAM for nixos-rebuild. Known issues:
|