Skip to main content

Install

We follow the UEFI part of the official Installation Guide:
NixOS Installation Guide.

Prepare Disk

Partitioning

Partition the storage using sudo fdisk /dev/sdb. In the interactive prompt partition the storage those settings:

  • 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)

Delete all Files on partitions with:

dd if=/dev/zero of=/dev/sdb1 bs=4096 status=progress
dd if=/dev/zero of=/dev/sdb2 bs=4096 status=progress

Label partitions

Label the partitions using those commands:

sudo mkfs.fat -F 32 /dev/sda1
sudo fatlabel /dev/sda1 NIXBOOT
sudo mkfs.ext4 /dev/sda2 -L NIXROOT

Mount partitions

Mount yourthe boot and root drives so we can access them and install NixOS:

sudo mount /dev/disk/by-label/NIXROOT /mnt
sudo mkdir -p /mnt/boot
sudo mount /dev/disk/by-label/NIXBOOT /mnt/boot

Create swap file

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

Install Nixos

Create NixOS config

Generate the config using sudo nixos-generate-config --root /mnt.

Then, edit the config using sudo -evim /mnt/etc/nixos/configuration.nix.nix.

Here are some sections of the mostconfiguration essentialyou changesshould to make:add:

...
  keep# the existing config

Keyboard layout

services.xserver.xkb.layout = "us"de";

# Add a user!

users.users.aliceelias = { isNormalUser = true; description = "Alice"; extraGroups = [ "wheel" ]; # Sudo access shell = pkgs.bash; home = "/home/alice"; };

Networking config (ie: wifi)

Configure bootloader device

boot.loader.grub.device = "/dev/sda"; # or "nodev" for EFI only

Install an editor to edit the configuration

environment.systemPackages = with pkgs; [ nanovim ]; # or vim!

...

To edit the hardware config, use sudo -evim /mnt/etc/nixos/hardware-configuration.nix.nix.

You can then update the file systems to use labels.labels and add the swapfile.

...

  

fileSystems."/" = { device = "/dev/disk/by-label/NIXROOT"; # ... };

fileSystems."/boot" = { device = "/dev/disk/by-label/NIXBOOT"; # ... };

swapDevices = [{ device = "/...

swapfile";

size = 2048; # 2GB }];

Install

NixOS

cd /mnt
sudo nixos-install

after installation: Run passwd to change user password.

If internet broke/breaks, set wpa_supplicant config flags to connect to wifi.

Then, try one of the following to rebuild without downloads

nixos-rebuild switch --option substitute false
nixos-rebuild switch --option binary-caches ""

installChange gitpassword with passwd to a password that works on de and en keyboard layout.

rebildReboot withinto experimentalthe featuresinstalled nix-command and flakeNixOs.

Add those lines to the configuration.nix file:

nix.settings.experimental-features = ["nix-command" "flakes" ];

networking.hostName = "eliasDesktop"; #or eiasLaptop for other configs environment.systemPackages = with pkgs; [ vim git ];

Rebuild the system with sudo nixos-rebuild switch and reboot to update the Hostname.

copyCopy the config repo with git clone https://github.com/4Lost/nixos-config and move it to /etc/nixos and rebuild

dontwith forgetsudo tonixos-rebuild add the correct hardware-configuration..switch.