How to Install NixOS: A Declarative, Developer-Friendly Linux Distribution

How to Install NixOS: A Declarative, Developer-Friendly Linux Distribution

how-to-install-nixos-a-declarative-developer-friendly-linux-distribution

Hi everyone, welcome to MusaBase! In this guide, I'll cover the installation of one of the most unique, reproduicble and declarative OS called NixOS. In this guide, you will learn, how to:

  • Download NixOS and create a bootable USB
  • Boot into Live NixOS ISO Environment
  • Configure the base setup
  • Hard disk partitioning (manual & auto)
  • Installing the NixOS
  • And finally, log into your freshly installed NixOS

By the end of this guide, you will have a NixOS running on your PC effortlessly. So without further ado, let's get started!

neofetch-nixos






What Makes the NixOS Unique?

The core concept that makes NixOS unique compared to other Linux distributions is its philosophy of reproducibility and declarative configuration. But what do we mean by reproducibility and declarative? It means that we manage our entire system, from installing packages to configuring services, through a single file (configuration.nix). Instead of manually tweaking things all over the place, we write what we want in our system, and NixOS builds it exactly as we described in the configruation.nix file. This feature let us easily roll back changes, reporduce setups across different machines, and maintain a clean, stable system. NixOS's powerful package manager, Nix, installs software in an isolated environment, avoiding the common headaches of broken dependencies. With NixOS, we get full control over our system with the ability to go back and forth smoothly. It's basically a dream Linux distribution for developers, sysadmins, and power users who want a consistent, safe and flexible system.




Prerequisites & System Requirements

I'm instaling NixOS on a UEFI firmware PC, though NixOS can be installed on older or legacy hardware. The steps are mostly the same, with just a few minor adjustments needed for older setups. The installation of NixOS using the graphical setup is really straightforward, we simple select the options we wnat for our system (e.g., language, timezone, locale, etc) and then click Next.

System Requirements

  • Processor: Any x86-64 or aarch64 compatiable architecture
  • Ram: 8GB is sufficient for a fully fledged NixOS system with desktop environment installed, but more Ram the better
  • Disk Space: 60 GB+ is recommended.
  • Network: Stable internet connection



Step 1: Download and Create a Bootable USB with NixOS

You can get the NixOS ISO from this official NixOS ISO Image site. The downloaded file will be in .ISO format. Once its downloaded you can easily create a USB bootable with NixOS iso image.

downalod-nixos-iso-image-from-nixos-org

1.1: Create a Bootable USB with NixOS

You can create a bootable USB with any of the following method your want:

1.1.1: Using Balena Etcher (GUI) on Windows/Mac/Linux
  • Download and install Balena Etcher.
  • Run Ethcer.
  • Select your NixOS.iso file.
  • Choose your USB stick from Etcher.
  • Click Flash! and after a few minutes your USB will be booted with NixOS ISO.
1.1.2: Using dd (CLI) if on Linux
  • Plug your USB stick into your PC.
  • Open terminal and run the following command to identify your USB:
lsblk
  • Look for your USB (e.g., /dev/sdb or /dev/nvme0n1). Note the name for your USB stick.
  • Unmount the USB (if mounted) by running:
sudo umount /dev/sdX
  • Next, write the nixos.iso to your USB by running the following command:
sudo dd if=/mnt/sdc1/Downloads/nixos.iso of=/dev/sda bs=4m status=progress oflag=sync
  • After dd finishes writing ISO to USB, eject your USB by running following command:
sudo eject /dev/sdX



Step 2: Boot into NixOS Live Installation Environment

  • Reboot your PC.
  • While your PC is turning on press F9, F10, F11, F12, DEL or ESC key (depending on your motherboard) to open UEFI/BIOS settings.
  • Locate and disable Secure Boot & Fast Boot options (usually they are under Security or Advanced Settings tab).
  • Save & Exit.
  • Next, again F9, DEL, ESC key to boot from your USB stick.
  • If everything goes right, then you would be greeted by NixOS GRUB menu.
  • Here the NixOS will ask if you want your installer to be in GNOME style or KDE Plasma style.
  • Pick the one you like, I'm going with the KDE style. But don't worry the steps are all the same.
choosing-kde-plasma-style-for-installing-nixos
  • NixOS will the installation the environment, and after a few seconds you will have the following screen:
kde-plasma-live-iso-for-nixos-installation



Step 3: Configure Basic Settings for System

In this step, we will do most of the basic settings (e.g., language, location, locale/keyboard layout, setting up user & root password, choosing desktop environment, etc.).

3.1: Choose Language

  • The very first configuration we get is choosing a language for our system.
  • Simply, choose you the language you want for your system and click on next. I'm choosing American English for my system.
nixos-choosing-language-for-system

3.2: Choose Location

  • Mostly the NixOS installer will autopick your location if you're connected to internet and your machine time is correct.
  • If the location is not correct, then pick your region (e.g., Europe, Asia, etc). and also zone (e.g., Dubia, London, etc.)
  • Also make sure, your Dates locale are set to the Locales in which you want your system to be (e.g., United States, etc) and click next.
nixos-choosing-region-zone-locale-for-system

3.3: Choose Keybaord Layout

  • For this settings, leave it as default, unless you want to change the keyboard model, encode ISO, and language.
nixos-choosing-keyboard-layout-for-system

3.4: Create User Account & Set Root Password

Creating user account and setting strong root password is a critical security step. Although we can use the NixOS system as only super user or root but it is not recommended. Because performing some critical changes or hardening the system as root may cause permanent damage to the system. So creating a user and performing admin level tasks by user with root access is safe and stable. To create a user do the following:

  • Fill in the field for What is your name?: type anyname you want (e.g., MusaBase).
  • Fill in the field for What name do you want to use to log in?: type any username you want (e.g., musabase).
  • For password, it is recommended to set a strong password which should be a combination of special characters ($,#,!), numbers (1,2,3) and alphabets. Though NixOS installer also provide option for short or easy password.
  • Next, for root password also make sure to use a strong password for root, becuase root have all the privileges.
nixos-choosing-keyboard-layout-for-system

3.5: Choosing Desktop Environment

  • In this step, I'm choosing Budgie for my system.
  • You can choose the one you like the most (e.g., KDE Plamsa, GNOME, Cinnamon etc) and press Next.
  • If your hardware is older then go with XFCE or LXQT. These two are lightweight and suited best for older hardware or devices with less resources.
nixos-choosing-desktop-environment-for-system

3.6: Unfree Software

"Unfree software refers to software that has restrictive licensing on modification and/or redistribution. This type of software cannot be freely provided or distributed in an official capacity." In other words, these are software packages that are propriertary, which limit users freedoms to use, study, or modify them. Such as Nvidia Graphics Drivers, Steam, Visual Studio COde, Google Chrome are Proprietary softwares. If you plan to install such software on your NixOS system, tick the checkbox so this feature can be enabled by default while the NixOS installation.

nixos-choosing-to-enable-feature-for-unfree-software-for-system



Step 4: Disk Partition

Creating Disk partitions is a crucial step while installing any OS. If not done right, it can delete an entire storage drive or the entire disk. NixOS provides us with two options for disk paritioning.

  • Auto disk partitioning.
  • Manual disk paritioning.

Auto disk partition option will erase all data on your selected storage drive and create new partitions as needed. However for this tutorial, I'm going with manual partition. Manual parition gives us more control over how much space each partition gets and which Filesystem to use for each partition.

4.1: Manual Partition

  • Select your disk from top dropdown menu.
  • Choose Manual partitioning and click Next.
nixos-manual-disk-partitioning
  • On the next dialogue screen click on New Partition Table.
  • In the pop-up window choose GUID Partition Table(GPT) and click OK. If you are installing NixOS on older hardware that doesn't support UEFI firmware then choose Master Boot Record(MBR)

4.1.1: Creating Boot Partition

  • Select Free Space and click on create.
nixos-manual-disk-partitioning-creating-boot-partition
  • Fill in the fields like this:
    • Size: 1500 MiB.
    • File System: fat32.
    • Mount Point: /boot.
    • FS Label: boot.
    • Flags: boot.
nixos-creating-uefi-boot-partition

4.1.2: Creating Swap Partition

  • Select Free Space and click on Create
  • For swap partition, fill the fields like this:
    • Size: 8500 MiB.
    • File System: linuxswap.
    • FS Label: swap.
    • Flags: swap.

4.1.3: Creating Root Partition

  • Select Free Space and click on Create.
  • For root partition, fill in the fields like this:
    • Size: 20717 MiB (or remaining disk space available).
    • File System: ext4.
    • Mount Point: /.
    • FS Label: root.
    • Flags: root.
  • After creating the partitions, your final layout should look like this:
nixos-manual-disk-partition-final-layout
  • Confirm the layout and click Next.



Step 5: Install NixOS

Now that all the base system configuration is done and on the summary page, the NixOS installer will show our configured Language, Location/Timezone, Keymap, User, Disk Partitions, etc. If everything is according to your preffered settings, click on Install

nixos-final-summary-of-base-system-configuration-before-finally-installing-nixos
  • If everything is set up correctly the NixOS installation will being.
  • It usually takes 5-10 minutes to install.
  • After the installation is done, the installer will ask you for rebooting the PC. Tick the checkbox for Restart now Click on Done and your PC will restart.
nixos-installed-successfully-now-reboot-your-pc



Step 6: Boot into Installed NixOS

After restart you will be greeted by Budgie login manager greeter.

nixos-budgie-login-manager-greeter
  • Here enter your user's password that you created during installation.
nixos-home-screen-on-budgie-desktop-environment

And you are in!




Up-Next for NixOS

In upcoming articles, I’ll explain what NixOS really is, a Linux distribution built around the Nix package manager that makes your whole system configuration declarative and reproducible. You’ll learn how NixOS handles packages in its special /nix/store, why that means you can safely install multiple versions of software without conflict, and how its atomic upgrades and rollbacks let you revert system changes if something goes wrong. We’ll also dive into features like user-level environments, isolated development shells, and portable configuration files, so you can replicate your setup on another machine by just copying a config file.

If you hit any issue while following my steps for installing NixOS on your machine or any error occured with your setup, please let me know in the comments. I'll be more than happy to help. And also share my posts with other on social media this will really help us grow.

This is it for this tutorial, 1O1 out, I'll see you in th next one!

Load comments