NixOS Installation Guide
This guide is a companion guide for the official manual. In addition to describing the steps from the official manual, it provides known good instructions for common use cases. When there is a discrepancy between the manual and this guide, the supported case is the one described in the manual.
Use this guide as a step-by-step guide, choices will be presented, use only the selected section, and continue at the section it tells you to at the end.
Installation target
NixOS can be installed on an increasing variety of hardware, including the usual x86-type hardware.
- A regular (Intel or AMD) desktop computer, laptop, or physically accessible server can follow the instructions in this page
- SBCs, like the Raspberry Pis, and other ARM boards can follow the instructions at NixOS on ARM
- Cloud and remote servers will find various instructions at NixOS friendly hosters
Installation method
NixOS, as with most Linux-based operating systems, can be installed in different ways.
- The classic way, booting from the installation media (described in this page)
- Booting the media from an existing Linux installation
Making the installation media
Since NixOS 14.11 the installer ISO is hybrid. This means it is bootable on both CD and USB drives. It also boots on EFI systems, like most modern motherboards and Mac* systems. Please read the #Hybrid image section on how to burn the ISO.
For NixOS 14.04 and earlier, please read #Using Unetbootin and the other sections below.
Hybrid image
First, download a NixOS ISO image or create a custom ISO. Then plug in a USB stick large enough to accomodate the image. Then follow the platform instructions:
On Linux:
- Find the right device with
fdisk -l
, let's say/dev/sdb
. - Burn with:
cp nixos-xxx.iso /dev/sdb
On OS X:
- Find the right device with
diskutil list
, let's saydisk2
. - Unmount with
diskutil unmountDisk disk2
. - Burn with:
sudo dd if=path_to_nixos.iso of=/dev/rdisk2 bs=64k
- Note the use of rdisk instead of disk, this makes a large speed difference. You can check the write speed with
iostat 2
in another terminal.
You could use Disk Utility to write the image but then you'd need to convert it first to a compatible format somehow.
On Windows:
- Download USBwriter.
- Start USBwriter.
- Choose the downloaded ISO as 'Source'
- Choose the USB drive as 'Target'
- Click 'Write'
- When USBwriter has finished writing, safely unplug the USB drive.
This should suffice to boot the installer. Otherwise look for other alternatives below.
UEFI note
The below is for BIOS installation. For UEFI installation see the manual.
Using Unetbootin
See → [NixOS_Installation_Guide/Unetbootin]
Using syslinux
Using syslinux.cfg
If you have trouble booting from a USB drive or sdcard with Unetbootin (I just got a blinking cursor instead of a bootloader on an Asus eee 1000) the procedure described on http://knoppix.net/wiki/Bootable_USB_Key should work. After preparing the sdcard with mkdiskimage and syslinux you can mount it and copy all the content from the NixOS iso:
$ mount -o loop ~/Downloads/nixos-graphical-0.1pre27337-i686-linux.iso /media/iso
$ rsync -av --progress /media/iso/ /media/sd-card/
The syslinux.cfg needs to be created manually, but the details can easily be derived from the grub.cfg on the NixOS install cd.
I specified the root device by UUID, to get the UUID:
blkid /dev/mmcblk0p1
The relevant section from the live cd: /media/sd-card/boot/grub/grub.cfg
menuentry "NixOS Installer / Rescue" { linux /boot/bzImage init=/nix/store/r7xhnzymi1ll49r4glf1dwr5y1alx0bl-system/init root=LABEL=NIXOS_INSTALL_CD_0.1pre27337 splash=verbose vga=0x317 initrd /boot/initrd }
can be used in the syslinux config file: /media/sd-card/syslinux.cfg (you should just need to update the init path and the root UUID / LABEL or device path)
DEFAULT linux LABEL linux SAY Now booting the kernel from SYSLINUX... KERNEL /boot/bzImage APPEND init=/nix/store/r7xhnzymi1ll49r4glf1dwr5y1alx0bl-system/init root=UUID=509C-63E2 ro initrd=/boot/initrd splash=verbose
Note: in place of using mkdiskimage, you can simply format your SDCard as a fat32 system and install syslinux on it:
mkdosfs -F32 /dev/mmcblk0p1 syslinux -s /dev/mmcblk0p1
Using Command-line Tools
- Download the ISO image from http://nixos.org/nixos/download.html.
- Prepare your USB stick. If it isn't yet partitioned to your liking, create a bootable partition on
/dev/sdb1
:fdisk /dev/sdb
And format it with:
mkdosfs /dev/sdb1
Add ext2 partitions if you like. If you want both 32-bit and 64-bit NixOS, you need at least two partitions. You can directly use the entire disk without partition if that's what you like. Once you have your VFAT (dosfs) block device, you should give it a label, within a 11-character limit, e.g.:
dosfslabel /dev/sdb1 NIXBOOT
- Mount the bootable USB partition with:
mkdir -p /media/NIXBOOT mount /dev/sdb1 /media/NIXBOOT
- Mount the ISO image with:
mkdir -p /media/iso mount -o loop ~/Downloads/nixos-graphical-0.2pre4463_5e88e9b-c877f45-x86_64-linux.iso /media/iso
- Copy the contents of the NixOS ISO (
/media/iso
) to your USB stick (/media/NIXBOOT
) with:rsync -av --progress /media/iso/ /media/NIXBOOT/
- Install a complete and recent GRUB to the USB stick with:
grub-install /dev/sdb --root-directory=/media/NIXBOOT/
- Edit the file
/media/NIXBOOT/boot/grub/grub.cfg
. Start from an existing grub.cfg, say from your hard drive or from another working bootable USB stick (e.g., from GRML.org). Then, merge in the entry for NixOS from/media/iso/boot/grub/grub.cfg
, modifying the LABEL to be that of your VFAT partition:menuentry "NixOS Installer / Rescue" { linux /boot/bzImage init=/nix/store/p94ckcksmhj90cr868cpcajrqgzwy57w-nixos-0.2pre4463_5e88e9b-c877f45/init root=LABEL=NIXBOOT initrd /boot/initrd }
- To share your USB stick with other distributions (e.g., GRML, or both 32- and 64- bit NixOS), you can move NixOS's bzImage and initrd to different location (e.g.,
/boot/nix32/
and/boot/nix64/
), and you appropriately edit the entries in your grub.cfg. If you have both nix32 and nix64, only one can have itsnix-store.squashfs
in the root of any given partition. That's where you can use a second partition, for the second one. For instance, copy the contents of your 64-bit NixOS to the first partition, with labelNIX64
, and copy the nix-store.squashfs of your 32-bit NixOS to the second partition with labelNIX32
(and create an empty nix/store). Copy the 32-bit kernel and initrd to/boot/nix32/
on the bootable partition, and edit the grub.cfg of the bootable partition accordingly. - There you go: you have a bootable NixOS USB drive, possibly allowing you to boot NixOS 64-bit, NixOS 32-bit, GRML 64-bit, GRML 32-bit, FreeBSD, FreeDOS, boot-sector-tetris, etc. Just you convince your BIOS to let you boot off it.
Build a custom installation image
NixOS provides an easy way to build a custom variant of the installation image. This might be useful to embed your own ssh key or enable additional features like zfs support. It allows to specify a custom configuration.nix
which is used to build the image
This is explained in Creating a NixOS live CD.
Installing on VPS & Cloud Providers
→ See NixOS friendly hosters
Special hardware
- Blog post how to install NixOS on a Dell 9560
- for embedded Hardware like the Raspberry Pi2 see NixOS on ARM
- Brand servers may require extra kernel modules be included into initrd (boot.initrd.extraKernelModules in configuration.nix) For example HP Proliant needs "hpsa" module to see the disk drive.