NixOS Installation Guide: Difference between revisions

imported>Matu3ba
m better performance for dd with flushing cache
imported>Matu3ba
add instructions from Til's Guide on youtube
Line 94: Line 94:


On the minimal ISO, or if you are more familiar with <code>wpa_supplicant</code> then you can also run <code>wpa_passphrase ESSID | sudo tee /etc/wpa_supplicant.conf</code>, then enter your password and <code>systemctl restart wpa_supplicant</code>.
On the minimal ISO, or if you are more familiar with <code>wpa_supplicant</code> then you can also run <code>wpa_passphrase ESSID | sudo tee /etc/wpa_supplicant.conf</code>, then enter your password and <code>systemctl restart wpa_supplicant</code>.
=== Partitioning ===
To partition the persistent storage run <code>sudo fdisk /dev/diskX</code> and follow instructions for DOS or (U)EFI.
A very simple example setup is given here.
==== DOS ====
* o (dos disk label)
* n new
* p primary (4 primary in total)
* 1 (partition number [1/4])
* 2048 first sector (alignment for performance)
* +500M last sector (boot sector size)
* rm signature (Y), if ex. => warning of overwriting existing system, could use wipefs
* n
* p
* 2
* default (fill up partition)
* default (fill up partition)
* w (write)
==== UEFI ====
* g (gpt disk label)
* n
* 1 (partition number [1/128])
* 2048 first sector
* +500M last sector (boot sector size)
* t
* 1 (EFI System)
* n
* 2
* default (fill up partition)
* default (fill up partition)
* w (write)
=== Label partitions ===
This is useful for having multiple setups and makes paritions easier to handle.
* lsblk
* sudo mkfs.fat -F 32 /dev/sdX1
* sudo fatlabel /dev/sdX1 NIXBOOT
* sudo mkfs.ext4 /dev/sdX2 -L NIXROOT
* sudo mount /dev/disk/by-label/NIXROOT /mnt
* sudo mkdir -p /mnt/boot
* sudo mount /dev/disk/by-label/NIXBOOT /mnt/boot
=== Swap file (only simple on uefi) ===
* sudo dd if=/dev/zero of=/mnt/.swapfile bs=1024 count=2097152 (2GB size)
* sudo chmod 600 /mnt/.swapfile
* sudo mkswap /mnt/.swapfile
* sudo swapon /mnt/.swapfile
=== NixOS config ===
* sudo nixos-generate-config --root /mnt
* cd /mnt/etc/nixos/
* sudo vim configuration.nix
Most essential changes:
1. keyboard layout, ie <code>services.xserver.layout</code>
2. <code>users.users.user</code> with adding entry <code>initialPassword = "pw123";</code>
3. networking (wifi), see below for fix if it breaks
4. <code>boot.loader.grub.device = "/dev/sda"; #or "nodev" for efi only</code>
5. install editor to edit the configuration
6. change hardware config to use labels
=== NixOS installation ===
* cd /mnt
* sudo nixos-install
after installation: Run <code>passwd</code> to change user password.
if internet broke/breaks, try one of the following:
* nixos-rebuild switch --option substitute false # no downloads
* nixos-rebuild switch --option binary-caches "" # no downloads
* wpa_supplicant flags to connect to wifi


<hr />
<hr />