Linux Operating system has a variety of distributions that are open-source and are compiled of components from different programmers. They mostly include a Linux Kernel, Desktop Environment, Package Manager, and GNU shell. Standard Linux distributions include Ubuntu, AlmaLinux, RHEL, CentOS, Solus, etc.

What is NixOS?

NixOS is one of the Linux Distributions that runs under Nix, a system configuration and package manager tool. It was developed to improve the state of art in system configuration management. The whole operating system including the kernel, system configuration files, and applications are built by the package manager. It started in 2003 as a research project then in 2015 NixOS Foundation was founded to support the project. Even though started as a research project, it came to be a functional operating system with hardware detection and systemd for managing system services.

NixOS releases are done twice a year in May and November in the format of YY:MM. The recent version is 21:11 which was released in November year 2021. NixOS is supported in i686 and x86_64 architectures. Desktop environments supported include; Awesome, Enlightenment, Fluxbox, GNOME, i3, IceWM, KDE Plasma, Ratpoison, and Xfce. Nix stores all packages in isolation from each other; as a result, there are no /bin, /sbin, /lib, or /usr directories, and all packages are kept in the /nix/store instead

Features

  • Ability to declaratively configure the whole system by specifying a specific configuration file for the whole system state.
  • Supports Multi-user package management.
  • Rollback to previous versions.
  • Reusable system configuration files.
  • Reproducible system packages are built in isolation from each other.
  • Collection of Thousands of packages to choose from for the package manager.

This guide will show you how to install NixOS from BIOS.

Step 1. Download the NixOS Disc Image file

To download the Disc Image file, Visit the Download page on the official website. Thre are 2 types of ISO files.

  • Graphical ISO image which contains the NixOS installer, Desktop environment, and several applications.
  • Minimal ISO image which does not have the graphical user interface and one runs the installer from the console.

Choose the one you prefer and click on download. I will be doing the graphical installation with the GNOME desktop environment.

Step 2. Create Bootable Medium

Once downloaded, we will create a bootable medium with the Ventoy tool on a USB drive. Download the latest version of the tool from the releases page.

Unzip the files

Run Ventoy2Disk-application to open the tool. Select the Disk to be used and click Install.

Then confirm twice that you want to format the disk.

The installation begins and you will receive a successful prompt window.

Then copy the disc image file that you have downloaded to the newly formatted USB drive.

And there you have a bootable drive with the NixOS ISO image.

Step 3. Booting the System with NixOS

Enter BIOS setup and select to boot from the USB drive. Select the installer.

The boot process begins.

Then you will log in to the system with the nixos and root accounts which have empty passwords. This means you can also use sudo with nixos user.

You will be welcomed with a screen prompt to take a tour or skip it. The desktop screen is shown below, Your screen will be different if you used the Plasma Installer.

You can access the applications via the Activities tab in the top right corner.

Step 4. Partitioning and Formating

There are 2 ways to format and partition the disk. You can use the GParted application or the terminal. I will use the GParted application which you can open from the applications.

Click on Create Partition and select the partition table type. This will erase all data on the selected disk.

Click on Partition, then new, Give its label a name, and click Add.

Click the ‘tick’ icon to apply the changes. You will be prompted with a message to confirm the partition. Click Apply.

The partition creates successfully.

The new partition is created successfully and can be seen on the GParted screen.

Step 5. Installing NixOS

The installation is manual. We will have to edit a configuration file that includes options for the installation.

Open the terminal from the applications and enter the root shell using the following command.

sudo su -

Mount the target file system on which NixOS should be installed.

# mount /dev/disk/by-label/nixos /mnt

Generate the NixOS configuration file that is already created by the installer using the following command.

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

Then edit the file using your favorite text editor.

# nano /mnt/etc/nixos/configuration.nix

There are different options that you will need to edit on the configuration file to install NixOS. I will go through the basic options to get started.

Specify on which disk the GRUB boot loader is to be installed. This requires you to uncomment the following line on the file.

boot.loader.grub.device = "/dev/sda";

The next option is to set the define the hostname

networking.hostname = "nixos";

Set the Timezone

time.timeZone = "Africa/Nairobi";

Next will be to set the localization details

i18n.defaultLocale = "en_US.UTF-8";
 console = {
     font = "Lat2-Terminus16";
     keyMap = "us";
};

Configure the display manager and desktop manager. You can also add another desktop environment to be installed.

services.xserver.displayManager.lightdm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
services.xserver.desktopManager.xfce.enable = true;

Enable sound.

sound.enable = true;
hardware.pulseaudio.enable = true;

If you are using a laptop, enable the touchpad support which might not be enabled for some desktop managers.

services.xserver.libinput.enable = true;

Create users and add groups for the user to be part of. I will only add one user and add the user to the group ‘wheel’ to enable sudo for the user.

users.users.technixleo = {
    isNormalUser = true;
    initialPassword = "PasswordDemo";
    extraGroups = [ "wheel" ]; #Enable 'sudo' for the user.
  };

Enable the packages you will want to install in the system profile. You can also add other packages to install within the brackets.

environment.systemPackages = with pkgs; [
    vim
    wget
    firefox
]

Save and exit the configuration file. With Nano press ctrl+x then y then press Enter.

Then run the installation using the following command. It might take some time to build the installation. At the end of the installation, you will be required to set the root password.

# nixos-install

Once the installation is done, reboot your system

# reboot

You will now be presented with the login page. You can choose the desktop environment to log in with. I will choose Plasma (Wayland) which was installed with the system.

Enter the password for the user we created.

The desktop appears as below.

And you can find information about the system on Settings>About this system.

The configuration file contains the current configuration of the system. If you change something on the file, You have to run the rebuild command for changes to take effect.

# nixos-rebuild switch

Upgrading NixOS system

The simple way to ensure NixOS updates automatically would be to add the following configurations on the configuration.nix file.

system.autoUpgrade.enable = true;
system.autoUpgrade.allowReboot = true;
system.autoUpgrade.channel = https://nixos.org/channels/nixos-latest;

Conclusion

This guide has shown you how to go about installing NixOS on your device. It might at the first try but once you understand how to go about it, It is easy peasy. For more installation information, access the NixOS manual, and for more configurations find the Configurations Options file. NixOS is a different type of Linux Distribution but a brilliant one at that.

LEAVE A REPLY

Please enter your comment!
Please enter your name here