The operating system is configured by providing an
operating-system declaration in a file that can then be passed to
guix system command (see Invoking guix system). A
simple setup, with the default system services, the default Linux-Libre
kernel, initial RAM disk, and boot loader looks like this:
(use-modules (gnu) ; for 'user-account', '%base-services', etc. (gnu packages emacs) ; for 'emacs' (gnu services ssh)) ; for 'lsh-service' (operating-system (host-name "komputilo") (timezone "Europe/Paris") (locale "fr_FR.UTF-8") (bootloader (grub-configuration (device "/dev/sda"))) (file-systems (cons (file-system (device "/dev/sda1") ; or partition label (mount-point "/") (type "ext3")) %base-file-systems)) (users (list (user-account (name "alice") (uid 1000) (group 100) (comment "Bob's sister") (home-directory "/home/alice")))) (packages (cons emacs %base-packages)) (services (cons (lsh-service #:port 2222 #:allow-root-login? #t) %base-services)))
This example should be self-describing. Some of the fields defined
above, such as
bootloader, are mandatory.
Others, such as
services, can be omitted, in
which case they get a default value.
packages field lists
packages that will be globally visible on the system, for all user
accounts—i.e., in every user’s
PATH environment variable—in
addition to the per-user profiles (see Invoking guix package). The
%base-packages variable provides all the tools one would expect
for basic user and administrator tasks—including the GNU Core
Utilities, the GNU Networking Utilities, the GNU Zile lightweight text
grep, etc. The example above adds
Emacs to those, taken from the
(gnu packages emacs) module
(see Package Modules).
services field lists system services to be made
available when the system starts (see Services).
operating-system declaration above specifies that, in
addition to the basic services, we want the
lshd secure shell
daemon listening on port 2222, and allowing remote
(see Invoking lshd in GNU lsh Manual). Under the hood,
lsh-service arranges so that
lshd is started with the
right command-line options, possibly with supporting configuration files
generated as needed (see Defining Services). See operating-system Reference, for details about the available
Assuming the above snippet is stored in the my-system-config.scm
guix system reconfigure my-system-config.scm command
instantiates that configuration, and makes it the default GRUB boot
entry (see Invoking guix system). The normal way to change the
system’s configuration is by updating this file and re-running the
guix system command.
At the Scheme level, the bulk of an
is instantiated with the following monadic procedure (see The Store Monad):
Return a derivation that builds os, an
object (see Derivations).
The output of the derivation is a single directory that refers to all the packages, configuration files, and other supporting files needed to instantiate os.