How to install NixOS Linux
NixOS is a fresh operating system. It’s not a derivative, but instead, a new take on Linux. It ships with a variety of different types of desktop environments and tries it’s best to offer a unique, efficient experience.
The NixOS project has a lot of goals, but the main focus is consolidating user configuration files in a universal space for ease of use, stability, reliability and most importantly, developer-friendly.
Downloading NixOS
To get your hands on it, you’ll need to go to the official website. Once on the official NixOS Linux website, look for the “Get NixOS” button and click on it with the mouse to be taken to the downloads page.
On the downloads page for NixOS, you’ll see a lot of information and links. Find the “Graphical Live CD” link and select it to instantly start the download process for the latest NixOS ISO image.
The file is about 1.1 GB in size, so downloading may take a bit of time, depending on your connection speed. Be patient and let the ISO file download. When it’s complete, it’ll appear in the “Downloads” folder on your computer.
Making the Live disk
Now that you’ve got your hands on the latest NixOS file, it’s time to create a bootable USB, so that the operating system will work on your PC. To do this, start by heading over to the Etcher.io website and download their app.
Extract the Etcher application and run it on your Mac, Linux or Windows PC. Then, while it’s running, follow the step-by-step instructions to learn how to create a bootable disk.
Step 1: Find the blue “Select image” button inside of the Etcher application and click on it with your mouse.
Step 2: After clicking on “Select image,” use the pop-up window that appears to browse for the NixOS ISO image on your system and click the “Open” button to add it.
Step 3: Take your USB flash drive out (of at least 2GB in size) and plug it into your computer.
Step 4: Locate the “Select drive” button in the Etcher application, and use the integrated pop-up menu to select the flash drive.
Step 5: Locate the “Flash!” button, and click it with the mouse to start the burning process! When everything is complete, reboot your Linux PC and configure it to load from USB.
Install NixOS
In the NixOS Grub menu, select the “Graphical Installer” option with theĀ Enter key. Upon selecting this option, you’ll be presented with a terminal prompt. Write in the following command to start the installation.
systemctl start display-manager
You’ll then be presented with a KDE Plasma desktop environment. From here, locate the Gparted icon and double-click on it to start the partitioner.
In the partitioner, follow these steps.
Note: using BIOS and not UEFI? Skip steps 4-6.
- Select the hard drive you want to install NixOS on in the menu on the top right.
- Select “Create Partition table.” For UEFI, set it to “GPT”. For BIOS, select “MS-DOS.”
- Right-click on the unallocated space in Gparted and select “New” to create a new partition.
- In the pop-up window for the new partition, locate “File system” and set it to Fat32. Then, write “boot” in the label, and put 512 in the box that states “New Size (MB).”
- Click “OK” to create the boot partition. Then, click the check-mark icon to create it.
- Right-click on the boot partition, select “manage flags.” After that, select the box that says “boot,” and “esp.”
- Right-click the free space once again and select “New.” Then, create a new partition.
- Set the second partition’s file system to linux-swap.
- Set the label of the new Swap partition to “Swap.”
- Click on “New Size (MB)” and write in 4096 (4 GB).
- Select the checkmark icon to create the new Swap partition.
- In Gparted, right-click on the Swap partition and select “Swapon” to activate Swap.
- Using the mouse, right-click on the unallocated space in Gparted and select “New” to create a third partition on the disk.
- In the partition creation window, set the file-system to Ext4 and the label to “Root.” The new Ext4 partition uses the rest of the drive.
- Select the checkmark icon for a third time to create the third partition.
- When done, the partition layout should look as pictured below. Please note that a BIOS layout will be missing the Fat32 partition.
With the partitioning done, close Gparted and double-click on the Konsole icon on the desktop to gain access to the command-line in the live disk. Then, run the lsblk command.
lsblk
Look at the lsblk output for the 3 partitions you just created. In this example, they are /dev/sda1 (boot), /dev/sda2 (swap), and /dev/sda3 (root).
Using the mount command, mount all of the partitions to the /mnt folder.
mount /dev/sda3 /mnt mkdir -p /mnt/boot mount /dev/sda1 /mnt/boot
Or, if you are doing a BIOS only setup, do the following. Keep in mind that in this instance, the Root partition is /dev/sda2, due to no Boot partition existing on the disk.
mount /dev/sda2 /mnt
Run the nixos-generate-config command to create a new config file.
nixos-generate-config --root /mnt
Open the configuration file with Nano.
nano -w /mnt/etc/nixos/configuration.nix
Make the following edits to the configuration file.
For UEFI users
In the config file, remove the # from:
networking.hostName = "nixos";
< – be sure also to change “nixos” to your preferred hostname.networking.wireless.enable = true
<- if you require WiFi.
For BIOS users
In the config file, remove the # from:
boot.loader.grub.device= "/dev/sda"
networking.hostName = "nixos";
< – be sure also to change “nixos” to your preferred hostname.networking.wireless.enable = true
<- if you require WiFi.
After making those necessary edits, look through the configuration file and remove # symbols from features and settings you want to enable. Don’t skim through these settings!
Note: to save with Nano, do Ctrl + O.
This is how your system will be set up when installed. For guidance on the config file, check here.
After generating a new configuration file, run the nixos-install command to install the operating system.
nixos-install
When the terminal is usable again, type reboot to load into your new NixOS system.
reboot