NixOS is a purely functional Linux distribution. It can be found on nixos.org. A main reason to use NixOS is because it is completely declarative, which makes upgrading systems more reliable, and provides many other advantages too. This guide will show you how to install NixOS on Vultr.
Installation
Upload ISO
Go to “My Servers > ISOs” in the Vultr dashboard. Add the following URL as an ISO.
https://nixos.org/releases/nixos/14.12/nixos-14.12.526.98b8eb6/nixos-minimal-14.12.526.98b8eb6-x86_64-linux.iso
The md5 must match “fe8cc2c587ddb14be447d14f1f380e5a”. Newer releases may be available on the official site.
Deploy the ISO
Go to “Deploy”, use the location of your choice, select “x64”, and pick “Custom”. Then, choose “Virtual ISO” and select the just uploaded ISO.
Place your order.
Open the console
After the VPS has finished launching, go to “Manage”, then open “View Console”.
Login as “root”, no password.
Partition and create the file system
Partition the disk.
fdisk /dev/vda
# create a primary partition
# use the "n" key, select "p" for primary, and the first partition (1).
# Select the suggested values for the size.
# Activate the partition, use "a", select the defaults.
# Write the changes to disk, using "w"
Format the disk.
mkfs.btrfs /dev/vda1 -Lroot
# It's possible to use ext4 instead of btrfs:
# mkfs.ext4 /dev/vda1 -Lroot
Mount the disk.
mount /dev/disk/by-label/root /mnt
Configure NixOS
Generate the basic configuration.
nixos-generate-config --root /mnt
Edit the newly generated configuration.
$EDITOR /mnt/etc/nixos/configuration.nix
Change the following values. For more options, you can look at the NixOS Manual: Options.
# Set the grub bootloader device to the correct
boot.loader.grub.device = "/dev/vda";
# Enable openssh
services.openssh.enable = true;
# Disable root login
services.openssh.permitRootLogin = "no";
# Add a user:
users.extraUsers.nixos = {
uid = 1000;
password = "nixos"; # Set this to something more secure.
extraGroups = ["wheel"];
useDefaultShell = true;
};
Install
nixos-install
# It will download the packages, install grub and set a root password.
If you have made a mistake, nixos-install
will throw an error. Edit the /mnt/etc/nixos/configuration.nix
file again. nixos-install
can be run as many times as necessary.
Reboot
Go back to the dashboard, and remove the ISO.
Reboot the instance.
Verify
SSH to the machine.
# Use the password set in `users.extraUsers.nixos.password`.
ssh nixos@IP
Snapshot your newly created machine
Open the Vultr dashboard and click on “Snapshot”. This will save a snapshot of your NixOS installation. From now on, you can deploy NixOS from a snapshot.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article