First of all, though it’s from SCRATCH, I suppose the reader know basic Linux concepts and commands and is able to use basic tools for os installation such as Vectory. Of course this is mainly based on my walk through, so remember using google to finish what is not mentioned for you.

I fell in love with Nix for the first I have it installed cause it is definitely what I am searching for after more than three years of Arch usage. I have reinstalled my Arch many times, and each time I have to reinstall the packages manually and spend time to change the configurations, it’s fun and I enjoy it. But recently I don’t have much time left for it, so NixOS is definitely what I want.

As for Hyprland, I found it very popular recently and it’s written in cpp, so I tried it with Arch from scratch and found it a fancy wm.


Download and boot from image

Get NixOS image here, I chose Minimal ISO image in my case.

To begin the installation, you have to boot your computer from the install drive.

  1. Plug in the install drive. Then turn on or restart your computer.
  2. Open the boot menu by pressing the appropriate key, which is usually shown on the display on early boot. Select the USB flash drive (the option usually contains the word “USB”). If you choose the incorrect drive, your computer will likely continue to boot as normal. In that case restart your computer and pick a different drive.

Setup WIFI (Optional)

There is no iwd preinstalled in NixOS like Arch, so use wpa_supplicant instead.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Bring the interface up
sudo ip link set wlan0 up

# Scan avaiable networks
sudo iw wlan0 scan | grep SSID

# Generate a wpa_supplicant config
wpa_passphrase "YourSSID" "YourPassword" | sudo tee /etc/wpa_supplicant.conf

# Start wpa_supplicant
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf

# Get an IP address
sudo dhcpcd wlan0

# Check connectivity
ping -c 4 8.8.8.8

# Optional: Stop wpa_supplicant
# sudo pkill wpa_supplicant

Try installing new packages

Before installing a new package, you may want to check if the package exists and how to install from here.

Most of the time, install a package like this:

1
nix-shell -p cmatrix

Partitioning and formatting

Run lsblk to see where you gonna install NixOS into, the output may looks like this:

1
2
3
4
5
NAME                         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme1n1 259:0 0 3.7T 0 disk
├─nvme1n1p1 259:1 0 16M 0 part
├─nvme1n1p2 259:2 0 515.4G 0 part
└─nvme1n1p3 259:3 0 300G 0 part

Suppose the nvme1n1p3 is what you want and you are SURE to format it:

1
sudo mkfs.ext4 -L nixos /dev/nvme1n1p3

Install NixOS

1
2
3
4
5
6
7
8
9
10
11
12
# Mount the target file system on which NixOS should be installed on `/mnt`
mount /dev/disk/by-label/nixos /mnt

# Suppose you UEFI partition is /dev/nvme1n1p1
mkdir -p /mnt/boot
mount /dev/nvme1n1p1 /mnt/boot

# Generate default configuration file
nixos-generate-config --root /mnt

# Edit configuration file
vim /mnt/etc/nixos/configuration.nix

(Optinal) 将清华源做为默认源,添加以下内容到配置文件大括号内

1
nix.settings.substituters = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" ];

在安装 NixOS 时临时使用清华源

1
nixos-install --option substituters "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"

For more detailed processes, check this


Start NixOS

Reboot and choose the NixOS just installed. Setup wifi following the same procedure above, and this time you can make it start automatically via systemctl enable --now wpa_supplicant.

Or you can use NetworkManager instead, procedure will not be presented here.


Install Hyprland

Edit /etc/nixos/configuration.nix and add following:

1
2
3
4
5
6
7
{
programs.hyprland = {
enable = true;
withUWSM = true; # recommended for most users
xwayland.enable = true; # Xwayland can be disabled.
};
}

Then install necessary packages, I use alacritty as my default terminal on Hyprland:

1
2
3
4
5
{
environment.systemPackages = with pkgs; [
alacritty
];
}

Rebuild NixOS:

1
sudo nixos-rebuild switch

Edit Hyprland’s config file ~/.config/hypr/hyprland.conf:

1
2
3
# change the default terminal from kitty to alacritty
# $terminal = kitty
$terminal = alacrityy

Start Hyprland.

1
uwsm start select

The end

The most basic setup has been done, you can now walk around the Hyprland and NixOS’s wiki and forums for more useful configurations and build up the final system that you want.

Enjoy!


See also


References