Files
NixOSGuide/src/installation/index.md
2025-07-16 19:55:50 +02:00

3.2 KiB

Installation

The first part of starting the installation is getting an install media. For this guide, the minimal will be assumed, and can be found here, at the bottom of the page.

Booting it, you will get a TTY. To be able to run all the commands without any issues, please run sudo -i to have root privileges. We are then able to setup some pleasantries, such as loadkeys sv-latin1 for a Swedish keyboard layout (Please lookup your own layout for other languages) and setfont ter-v32n for a larger font.

If you want WIFI, run systemctl start wpa_supplicant and then wpa_cli. This is then followed by something like the following

> add_network
0

> set_network 0 ssid "myhomenetwork"
OK

> set_network 0 psk "mypassword"
OK

> enable_network 0
OK

> quit

You should now have network, if you used the right ssid and psk.

It is now time to setup your disks. I prefer to use cfdisk, since it is a nice way to see all the current allocations. In cfdisks TUI, follow the following steps, for the disk that you want to partition

  • gpt
  • New 512M
  • Type (EFI System)
  • New (Size left minus amount of ram)
  • New (Rest)
  • Type (Linux Swap)
  • Write
  • Quit

The disk have now been partitioned, but need to be formatted. To get the names of the disk you can run lsblk. In my case, when I was installing it in a VM, I was able to see that it was vda that was the relevant part. Usually, installations on hardware care about sdx or nvme0nX.

> lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0  1.5G  1 loop /nix/.ro-store
sr0     11:0    1  1.6G  1 rom  /iso
sr1     11:1    1 1024M  0 loop
vda    253:0    0   32G  0 disk
├─vda1 253:1    0  512M  0 part
├─vda2 253:2    0   28G  0 part
└─vda3 253:3    0  3.5G  0 part

With the devices known, run the following commands.

> mkfs.fat -F 32 -n boot /dev/vda1
> mkfs.ext4 -L nixos /dev/vda2
> mkswap -L swap /dev/vda3

mkfs.fat is to make the boot disk, and ensure that it is Fat32, with the name boot. Similarly, mkfs.ext4 creates the root file system, with the name nixos, and mkswap to create the swap.

We are now able to mount the future system, using

> mount /dev/disk/by-label/nixos /mnt
> mkdir -p /mnt/boot
> mount -o umask=077 /dev/disk/by-label/boot /mnt/boot
> swapon /dev/disk/by-label/swap

With the system mounted, you can install using the following

> nixos-generate-config --root /mnt --flake
writing /mnt/etc/nixos/hardware-configuration.nix...
writing /mnt/etc/nixos/flake.nix...
writing /mnt/etc/nixos/configuration.nix...
For more hardware-specific settings, see https://github.com/NixOS/nixos-hardware.
> nixos-install --flake /mnt/etc/nixos/.#nixos
...

Post install

TODO: adding a user and git.

Further reading

With this you have an installed system, with a user, but not much more. How to configure the system, to add users, software, drivers and such, will be covered in Configuration. But, you might need to understand some aspects of the nix language in order to fully understand how to do configuration, so that will be covered in Nix basics.