Terminal GuideTerminal Guide

NixOS Guide

NixOS is a Linux distribution built on the Nix package manager, featuring declarative configuration and atomic upgrades that enable reproducible system builds.

12 min readLast updated: January 19, 2026
Dai Aoki

Dai Aoki

CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm

Overview

NixOS was first released in 2003, pioneering the declarative approach to system configuration. Your entire system is defined in configuration files, making it reproducible and version-controllable.

Quick Facts

Based OnIndependent (Nix package manager)
Package ManagerNix
Default DesktopGNOME or KDE (user choice)
Release CycleEvery 6 months + unstable
Support Period~7 months per stable release
Init Systemsystemd
Info
NixOS takes a fundamentally different approach to Linux. The learning curve is significant, but the benefits for reproducibility and rollback are unmatched.

Who Should Use NixOS?

  • DevOps engineers - Infrastructure as code for your OS
  • Developers - Reproducible development environments
  • Power users - Version-controlled system configuration
  • Experimenters - Easy rollback when things break
  • Teams - Share identical development setups

Installation

NixOS can be installed graphically or via command line:

bash
# Generate initial configuration
sudo nixos-generate-config --root /mnt

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

# Install the system
sudo nixos-install

# After reboot, rebuild system with changes
sudo nixos-rebuild switch

Package Management

Nix offers multiple ways to manage packages:

bash
# Search for packages
nix search nixpkgs firefox

# Try a package without installing
nix-shell -p package-name

# Install package imperatively (user level)
nix-env -iA nixpkgs.firefox

# Remove package
nix-env -e firefox

# List installed packages
nix-env -q

# Update all packages
nix-channel --update
nix-env -u '*'

# Garbage collect old generations
nix-collect-garbage -d

# Recommended: Use flakes (modern approach)
nix profile install nixpkgs#firefox
Tip
For most packages, declare them in your configuration.nix rather than using nix-env. This keeps your system reproducible.

Key Features

Declarative Configuration

Your entire system is defined in configuration.nix. Share it with others to reproduce your exact setup.

Atomic Upgrades

System updates are atomic. If something fails, the system remains in its previous consistent state.

Rollbacks

Every system generation is preserved. Boot into any previous configuration from GRUB.

Development Shells

Create isolated development environments with shell.nix or flake.nix files.

Declarative Configuration

Here's an example configuration.nix:

bash
# configuration.nix example
{ config, pkgs, ... }:

{
  # Boot loader
  boot.loader.systemd-boot.enable = true;

  # Networking
  networking.hostName = "my-nixos";
  networking.networkmanager.enable = true;

  # Desktop environment
  services.xserver.enable = true;
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  # Users
  users.users.myuser = {
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" ];
  };

  # Packages
  environment.systemPackages = with pkgs; [
    firefox
    git
    vim
    vscode
  ];

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

  system.stateVersion = "24.05";
}

FAQ

Is NixOS hard to learn?

Yes, it requires learning the Nix language and a different mental model. However, the investment pays off in system reliability and reproducibility.

Can I use Nix without NixOS?

Yes! The Nix package manager works on any Linux distribution and macOS. You can benefit from Nix without switching your OS.

What are Nix flakes?

Flakes are the modern way to manage Nix projects with better reproducibility and dependency management. Enable them in your configuration.

Summary

NixOS represents the future of reproducible system configuration. Key takeaways:

  • Declarative system configuration in Nix language
  • Atomic upgrades and easy rollbacks
  • Reproducible builds across machines
  • Over 80,000 packages in nixpkgs
  • Steep learning curve but powerful benefits

Official Documentation

For authoritative information, refer to the official documentation:

Related Articles