YOUR JOURNEY
07 / 18
02THE NIXOS SYSTEM 6 MIN READ
LESSON 07 / A SYSTEM IN A FILE

Beyond packages.
Your whole OS.

NixOS applies the same model to your operating system.

Packages, services, and system settings become declarations. Change the configuration, build it, and activate a new generation.

Explore the lesson
~$ NixOS examples · try them in a VM.
THE NIX MODEL01 / 03
Drag to rotate

Declare what the machine should provide.

packagesservicesusersconfiguration.nix
07.1A DIFFERENT SCOPE

Now the system is the project.

The examples in this chapter apply to an installed NixOS system. On another Linux distribution, keep using Nix for packages and development environments. A NixOS VM is a good place to explore these system changes.

The installer creates a starting configuration, usually under /etc/nixos. Keep its hardware configuration, boot settings, filesystem settings, and existing system.stateVersion. The following is an addition, not a replacement for that generated file.

configuration.nix · illustrative excerpt
{ config, pkgs, ... }: {
  imports = [ ./hardware-configuration.nix ];
 
  networking.hostName = "workstation";
  environment.systemPackages = [
    pkgs.git
    pkgs.hello
  ];
 
  # Keep your existing boot, filesystem,
  # user, and system.stateVersion settings.
}
Next section: Files and databases still live their lives.
07.2CONFIGURATION IS NOT ALL STATE

Files and databases still live their lives.

NixOS can describe how a service is configured. It does not make the service’s database, your home directory, or every runtime file immutable. Separate configuration management from backups.

Read the configuration as a desired state: this machine has this hostname and these system packages. NixOS translates options into the lower-level files and services that implement it.

TAKE THIS WITH YOU

NixOS declares system configuration. Mutable data still needs its own backup and migration plan.

Go a little deeperNixOS configuration manual
UP NEXT

Compose with modules

Split a configuration by responsibility, then compose it.

Next lesson