How to Install NixOS: Declarative Linux Installation Guide
declarative linux developer workflow functional package management howto linux linux installation nixos open source os reproducible systems system configuration
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
Expand
- 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
Expand
- 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!
Frequently Asked Questions: NixOS Installation
What makes NixOS different from other Linux distributions?
NixOS is built around a declarative configuration model. Instead of manually installing packages and tweaking system files, you define your entire system (packages, services, settings) in a single configuration file (configuration.nix). NixOS then builds that exact state reproducibly. This allows atomic upgrades, easy rollbacks, and the ability to reproduce the same setup on multiple machines without conflict. It also uses the Nix package manager which stores packages in isolation, eliminating dependency hell.
What are the minimum system requirements for NixOS?
NixOS requires a 64-bit x86-64 or AArch64 processor. For a comfortable desktop experience, at least 8GB RAM is recommended (more for heavy builds). Disk space should be 60GB+ to accommodate system generations and rollbacks. A stable internet connection is necessary for downloading packages during installation.
How do I download the NixOS ISO?
You can download the official NixOS ISO from the NixOS downloads page. Choose the appropriate ISO for your architecture (usually the graphical ISO for a desktop environment). The file will be in .iso format.
How do I create a bootable USB for NixOS?
You can use Balena Etcher (GUI) on Windows, Mac, or Linux: select the ISO, choose your USB, and click Flash. Alternatively, use the dd command on Linux:
sudo dd if=/path/to/nixos.iso of=/dev/sdX bs=4M status=progress oflag=sync
Replace /dev/sdX with your USB device (check with lsblk). Be extremely careful to avoid overwriting your hard disk.
Do I need to disable Secure Boot and Fast Boot before installing NixOS?
Yes, it is recommended to disable Secure Boot and Fast Boot in your UEFI/BIOS settings before booting from the USB. These features can interfere with the boot process. They are usually found under the Security or Boot sections.
What options are available when booting the NixOS live USB?
The NixOS live ISO presents a GRUB menu where you can choose between a GNOME or KDE Plasma style installer. Both lead to the same graphical installation wizard, just with different desktop environments in the live session. Pick whichever you prefer.
How do I configure the base system settings in the NixOS installer?
The graphical installer guides you through:
- Language: Choose your system language.
- Location: Set your region and timezone; locale is auto-detected if online.
- Keyboard layout: Usually defaults to US; you can change it.
- User account: Provide full name, username, and password (strongly recommended).
- Root password: Set a strong root password for administrative tasks.
- Desktop environment: Pick from options like Budgie, KDE Plasma, GNOME, XFCE, etc.
- Unfree software: Check this box if you plan to install proprietary software like NVIDIA drivers, Steam, or Google Chrome (enables the allowUnfree option).
What is the "unfree software" option in the NixOS installer?
This option enables the installation of proprietary (non-free) software from the Nixpkgs repository. If you need packages like nvidia-xconfig, steam, or google-chrome, you should check this box. It sets nixpkgs.config.allowUnfree = true in your configuration.
What are the disk partitioning options in the NixOS installer?
The installer provides two modes:
- Automatic partitioning: Erases the selected disk and creates a default layout. Simple but less flexible.
- Manual partitioning: Gives you full control over partition sizes, filesystems, and mount points. Recommended for advanced users.
How do I manually partition my disk for NixOS (UEFI)?
In the manual partitioner:
- Select your disk and choose Manual partitioning.
- Click New Partition Table and select GPT (for UEFI).
- Create partitions in this order:
- Boot partition: Size at least 1500 MiB, filesystem FAT32, mount point /boot, flags boot.
- Swap partition: Size e.g., 8500 MiB, filesystem linuxswap, label swap.
- Root partition: Use remaining space, filesystem ext4, mount point /, label root.
- Verify the layout and click Next.
The boot partition must be at least 1GB; otherwise the installer may not proceed.
How long does the NixOS installation take?
The installation process typically takes 5 to 10 minutes, depending on your internet speed and hardware. The system downloads and builds packages from the Nixpkgs repository. After completion, you will be prompted to reboot.
What should I do after the first reboot?
After rebooting, you will see the login manager of your chosen desktop environment. Enter the user password you created during installation. Once logged in, you can start using NixOS. The system is ready for further customization by editing /etc/nixos/configuration.nix and running sudo nixos-rebuild switch.
How do I update NixOS after installation?
To update your system, you can use:
sudo nixos-rebuild switch --upgrade
This fetches the latest Nixpkgs channel, rebuilds your configuration, and switches to the new generation. If something goes wrong, you can roll back by selecting a previous generation from the GRUB menu.
What are NixOS generations and how do I roll back?
Each time you rebuild your system (e.g., after changing configuration or updating), NixOS creates a new generation. These are bootable snapshots. If an update causes issues, you can reboot and select a previous generation from the GRUB menu. You can also list generations with sudo nix-env --list-generations and roll back with sudo nixos-rebuild switch --rollback.
What are common mistakes when installing NixOS?
- Not disabling Secure Boot or Fast Boot in BIOS.
- Incorrect partitioning: forgetting to set the boot flag on the EFI partition or making the boot partition too small (under 1GB).
- Not enabling unfree software if you plan to install proprietary applications later (can be enabled manually in config).
- Forgetting to set a root password (the installer requires it).
- Choosing an underpowered desktop environment for old hardware (e.g., GNOME on a system with 2GB RAM).
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.
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!