Install NixOS: PC, Mac, WSL

NixOS can be installed on bare metal, in a VM, on macOS (via nix-darwin), and even inside Windows (via WSL). This guide covers all major scenarios with examples and configuration tips.


1. Install NixOS on a PC (Bare Metal or VM)

Download and Boot

  • Download the latest ISO: https://nixos.org/download.html

  • Write to USB: sudo dd if=nixos-*.iso of=/dev/sdX bs=4M status=progress

  • Boot from USB and select "Install NixOS."

Partition, Format, and Mount

Example (UEFI, single disk):

parted /dev/sda -- mklabel gpt
parted /dev/sda -- mkpart primary 512MiB 100%
parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
parted /dev/sda -- set 2 esp on
mkfs.ext4 /dev/sda1
mkfs.fat -F 32 /dev/sda2
mount /dev/sda1 /mnt
mkdir /mnt/boot
mount /dev/sda2 /mnt/boot

Generate and Edit Configuration

Example minimal config:

Install and Reboot


2. Install NixOS in a VM

  • Use any hypervisor (VirtualBox, VMware, QEMU, Parallels, etc.).

  • Attach the ISO, follow the same steps as above.

  • For QEMU (Linux):


3. Nix on macOS (nix-darwin)

Install Nix Package Manager

Install nix-darwin

Example ~/.nixpkgs/darwin-configuration.nix

Apply config:


4. NixOS on WSL (Windows Subsystem for Linux)

Install NixOS-WSL

  • Prerequisite: WSL2 enabled, Ubuntu or other WSL Linux installed.

  • Install NixOS-WSL:

Configure NixOS-WSL

Edit /etc/nixos/configuration.nix as usual. Example:

Apply changes:


References

NixOS can be run and managed on nearly any platform, with full reproducibility and declarative configuration.

Last updated