-
Notifications
You must be signed in to change notification settings - Fork 5
Fresh NixOS installation
This page covers the installation of NixOs with instantOS tools.
The procedure to install NixOS varies and there are many special cases, depending on the target system (e.g. you can create VM images or your very own install medium, you can deploy packages directly to an existing system and/or use NixOps as an orchestrator, a.s.o.). We're are covering a simple, very quick way here. Most notably this guide assumes, NixOS will be the only operating system and can delete everything on disk.
For special cases, please refer to the NixOS manual or other resources (dual booting Ubuntu or Windows 10).
If you need help or have suggestions, the quickest point of contact is the instantOS Discord server.
# After booting from the installation medium:
sudo -s # work as root
ping -c2 nixos.org # check connectivity
cat /proc/partitions; ls -al /dev/disk/* # figure out which disk to install to
# Partition that disk, create filesystems and mount
parted --script "${DISK}" -- \
mklabel gpt \
mkpart esp fat32 1MiB 1GiB \
mkpart primary 1GiB 100% \
set 1 boot on
mkfs.fat -F 32 -n BOOT /dev/sda1
mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt/
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot/
# Configure the new system
nixos-generate-config --root /mnt/
nix-env -i curl
cd /etc/nixos
curl https://raw.githubusercontent.com/instantOS/instantNIX/master/utils/configuration.nix > configuration.nix
vi configuration.nix # edit according to comments and preferences
nixos-install
reboot # remember removing install medium
The latest minimal ISO is available here:
Download and then boot from it on your target system. Make sure your system boots in EFI modes, as we're covering EFI installation here, only.
After booting from the installer medium, make sure you have a working internet connection:
$ ping -c2 nixos.org
[...]
2 packets transmitted, 2 received, 0% packet loss
We are creating a boot partition and one additional partition for the system here, forgoing swap space and any other fanciness, such as disk-encryption and/or ZFS (if you want all three, look at confus' install script). Form here on out, we are assuming that you're working as root, i.e. have run sudo -s
or a similar command.
First, you will have to find out what disk to install to. Take a look around your disks and partitions with:
# cat /proc/partitions
# ls -al /dev/disk/by-id /dev/disk/by-label
We assume, you are installing to /dev/sda
from here on out.
Danger! The following commands will lead to data-loss and a broken system if used on the wrong disk!
# parted --script /dev/sda -- \
mklabel gpt \
mkpart esp fat32 1MiB 1GiB \
mkpart primary 1GiB 100% \
set 1 boot on
# mkfs.fat -F 32 -n BOOT /dev/sda1
# mkfs.ext4 /dev/sda2
# mount /dev/sda2 /mnt/
# mkdir /mnt/boot
# mount /dev/sda1 /mnt/boot/
This step is mostly described in Installation with NixOS.
Here is a quick rundown on what to do:
- Have the live medium create a basic configuration, running:
Make sure everything is correct in
# nixos-generate-config --root /mnt/
/mnt/etc/nixos/hardware-configuration.nix
- Install curl by running
nix-env -i curl
- Download the configuration template for instantNIX:
# cd /mnt/etc/nixos # curl https://raw.githubusercontent.com/instantOS/instantNIX/dev/utils/configuration.nix > configuration.nix
- Edit
configuration.nix
according to comments and customize it to your liking
You should now be good to run
# nixos-install
This will download and/or build all the packages you need and put then in their place on the new system. For a typical modern system, the process will take about 10-15 minutes. The time depends on your hardware, internet connection and how extensive your configuration is.
After the process has completed, eject the installation medium and reboot.
You should have see a basic login prompt (lightdm).