Chapter 2
Declarative System Configuration
Step into the world of fully declarative configuration, where the entire system state is shaped by transparent, reproducible code rather than opaque scripts or brittle runbooks. This chapter unpacks how Guix empowers administrators and developers to define, reason about, and evolve complete systems-users, services, filesystems, networks, locales, and hardware-with precision and confidence. Discover how declarative methods not only prevent configuration drift but also pave the way for automated, auditable, and reproducible infrastructure at scale.
2.1 Operating-System Declarations
Guix's approach to operating-system configuration leverages the full expressive power of Scheme to create first-class declarative system descriptions. Unlike traditional configuration methods relying on imperative scripts or static configuration files, Guix treats the entire operating-system declaration as a Scheme object. This enables not only a uniform representation of system states but also composability, modularity, and precise control over system evolution.
At its core, the operating-system declaration is a Scheme record built using the operating-system form, which specifies key parameters such as installed packages, service bundles, user accounts, file system mounts, and various system settings. The primary form takes the following shape:
(operating-system (hostname "example-host") (timezone "UTC") (locale "en_US.UTF-8") (packages (cons* gcc glibc coreutils %base-packages)) (services (cons* (ssh-service) (gnome-service) %base-services)) (users (list (user-account (name "alice") (home-directory "/home/alice") (shell (string-append %bash "/bin/bash"))))) (file-systems (list (file-system (device "/dev/sda1") ...