How to Install NixOS: Declarative Linux Installation Guide

How to Install NixOS: Declarative Linux Installation Guide

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

What if your entire operating system was just a single text file? This isn't just a concept; it's the core philosophy behind NixOS, a distribution that is redefining how we think about system stability and deployment

Welcome back to MusaBase! In today's guide, I will cover the installation of one of the most unique, reproducible, and declarative operating systems available today: NixOS.

NixOS stands out in the Linux world due to its revolutionary approach to system management, where your entire environment is defined in a single configuration file. If you are interested in this modern breed of "immutable" and "atomic" operating systems, you might also want to check out my later guide on installing Fedora Silverblue for a different take on the same philosophy. In this comprehensive NixOS walkthrough, you will learn how to:

  • Download the NixOS ISO and create a bootable USB drive
  • Boot into the Live NixOS environment
  • Configure the base system settings for a stable build
  • Handle hard disk partitioning (manual and automatic methods)
  • Execute the NixOS installation process smoothly
  • And finally, log into your freshly installed NixOS system

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







What Makes NixOS Unique?

The core concept that distinguishes NixOS from other Linux distributions is its declarative and reproducible philosophy. But what exactly do we mean by these terms? In a declarative system, you manage the entire environment—from package installation to system services—through a single file (configuration.nix). Instead of manually executing commands and tweaking settings across various directories, you simply define the desired state of your system in this configuration file, and NixOS builds it exactly as described.

This unique approach allows you to effortlessly roll back changes, reproduce setups across multiple machines, and maintain a highly stable environment. NixOS's powerful package manager, Nix, installs software in isolated environments (the Nix store), effectively eliminating the "dependency hell" often found in traditional distros. With NixOS, you gain full control over your system with the ability to revert to previous generations if a configuration fails. It is truly a dream distribution for developers, sysadmins, and power users who demand a consistent, safe, and flexible computing experience.




Prerequisites & System Requirements

I am installing NixOS on a UEFI firmware PC, although NixOS can be installed on legacy hardware as well. The process remains largely the same, with only minor adjustments required for older setups. Installing NixOS via the graphical installer is remarkably straightforward—you simply select your preferred system options (such as language, timezone, and locale) and proceed through the intuitive setup wizard.

Minimum System Requirements

  • Processor: Any x86-64 or AArch64 compatible architecture.
  • RAM: 8GB is sufficient for a fully-featured NixOS system with a desktop environment, though more RAM is always beneficial for building configurations.
  • Disk Space: 60GB+ is recommended to accommodate system rollbacks and generations.
  • Network: A stable internet connection is required to fetch packages during installation.



Step 1: Download NixOS and Create a Bootable USB

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


1.1: Create a Bootable USB with NixOS

You can create a bootable USB using any of the following methods:

1.1.1: Using Balena Etcher (GUI) on Windows/Mac/Linux
  • Download and install Balena Etcher.
  • Run Etcher.
  • Select your NixOS.iso file.
  • Choose your USB stick from Etcher.
  • Click Flash! and after a few minutes, your USB will be bootable with the NixOS ISO.
1.1.2: Using dd (CLI) if on Linux
  • Plug your USB stick into your PC.
  • Open a 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 the ISO to the USB, eject your USB by running the following command:
sudo eject /dev/sdX



Step 2: Boot into the NixOS Live Installation Environment

  • Reboot your PC.
  • While your PC is turning on, press F9, F10, F11, F12, Del, or Esc (depending on your motherboard) to open UEFI/BIOS settings.
  • Locate and disable Secure Boot and Fast Boot options (usually found under Security or the Advanced Settings tab).
  • Save and exit.
  • Next, press F9, Del, or Esc again to boot from your USB stick.
  • If everything goes correctly, you'll be greeted by the NixOS GRUB menu.
  • NixOS will ask whether you want your installer in GNOME style or KDE Plasma style.
  • Pick the one you prefer. I'm going with KDE style, but don't worry—the steps are all the same.
  • NixOS will load the installation environment, and after a few seconds you'll see the following screen:



Step 3: Configure Basic System Settings

In this step, we'll configure 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 first configuration option is choosing a language for your system.
  • Simply select the language you want for your system and click Next. I'm choosing American English for my system.

3.2: Choose Location

  • Mostly, the NixOS installer will auto-pick your location if you're connected to the internet and your machine time is correct.
  • If the location is not correct, pick your region (e.g., Europe, Asia, etc.) and zone (e.g., Dubai, London, etc.).
  • Also, make sure your date locale is set to the locale you want for your system (e.g., United States) and click Next.

3.3: Choose Keyboard Layout

  • For this setting, leave it as default unless you want to change the keyboard model, encoding, or layout.

3.4: Create User Account & Set Root Password

Creating a user account and setting a strong root password is a critical security step. Although you can use the NixOS system as only super user or root, it is not recommended because performing critical changes or hardening the system as root may cause permanent damage. Creating a user and performing admin-level tasks with root access is safer and more stable. To create a user, do the following:

  • Fill in the field for What is your name?: Type any name 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 the password, it is recommended to set a strong password that should be a combination of special characters ($, #, !), numbers (1, 2, 3), and alphabets. The NixOS installer also provides an option for a short or easy password.
  • Next, for the root password, make sure to use a strong password because root has all privileges.

3.5: Choose Desktop Environment

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

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 proprietary, which limit users' freedoms to use, study, or modify them. Examples include NVIDIA Graphics Drivers, Steam, Visual Studio Code, and Google Chrome, which are proprietary software. If you plan to install such software on your NixOS system, tick the checkbox so this feature can be enabled by default during the NixOS installation.




Step 4: Disk Partitioning

Creating disk partitions is a crucial step when installing any OS. If not done correctly, it can delete an entire storage drive or disk. NixOS provides two options for disk partitioning:

  • Auto disk partitioning
  • Manual disk partitioning

The auto disk partition option will erase all data on your selected storage drive and create new partitions as needed. For this tutorial, I'm going with manual partitioning. Manual partitioning gives you more control over how much space each partition gets and which filesystem to use for each partition.

4.1: Manual Partitioning

  • Select your disk from the top dropdown menu.
  • Choose Manual partitioning and click Next.
  • On the next dialog screen, click 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, choose Master Boot Record (MBR).

4.1.1: Creating Boot Partition

  • Select Free Space and click Create.
  • Fill in the fields as follows:
    • Size: 1500 MiB
    • File System: FAT32
    • Mount Point: /boot
    • FS Label: boot
    • Flags: boot

4.1.2: Creating Swap Partition

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

4.1.3: Creating Root Partition

  • Select Free Space and click Create.
  • For the root partition, fill in the fields as follows:
    • 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:
  • Confirm the layout and click Next.



Step 5: Install NixOS

Now that all the base system configuration is complete, the NixOS installer will show a summary of your configured settings including language, location/timezone, keymap, user, and disk partitions. If everything matches your preferred settings, click Install.

  • If everything is set up correctly, the NixOS installation will begin.
  • The installation usually takes 5-10 minutes.
  • After the installation is complete, the installer will prompt you to reboot your PC. Check the Restart now checkbox, click Done, and your PC will restart.



Step 6: Boot into the Installed NixOS

After restarting, you'll be greeted by the Budgie login manager.

  • Enter the user password you created during installation.

And you're in!



What’s Next for NixOS?

In upcoming articles, I will dive deeper into the mechanics of NixOS—a distribution built entirely around the Nix package manager that makes your system configuration truly declarative and reproducible. You will learn how NixOS handles packages within the /nix/store, allowing you to install multiple software versions without conflicts. We will also explore how its atomic upgrades and rollbacks let you revert system changes instantly if something goes wrong.

Expand Your Linux Knowledge

πŸ›‘️ Immutable Alternatives: If you enjoy the concept of atomic updates but want a different workflow, check out my guide on installing Fedora Silverblue.

⚙️ Manual Control: For those who want to build their system from the ground up without a declarative manager, follow my Complete Arch Linux Installation Guide.

We will soon cover advanced features like isolated development shells and Home Manager, which allow you to replicate your entire setup on any machine by just copying a single config file. Stay tuned for those updates!

If you hit any issues while following my NixOS installation steps or if any error occurs with your setup, please let me know in the comments below. I will be more than happy to help. Also, sharing this post on social media really helps MusaBase grow and reach more Linux enthusiasts.

That is it for this tutorial. 101 out, I’ll see you in the next one!

Load comments