Skip to content
Snippets Groups Projects
guix.texi 439 KiB
Newer Older
  • Learn to ignore specific revisions
  • Stand-alone GNU Info}).  The installation system runs the GPM mouse
    daemon, which allows you to select text with the left mouse button and
    to paste it with the middle button.
    
    @quotation Note
    Installation requires access to the Internet so that any missing
    dependencies of your system configuration can be downloaded.  See the
    ``Networking'' section below.
    @end quotation
    
    
    The installation system includes many common tools needed for this task.
    But it is also a full-blown GuixSD system, which means that you can
    install additional packages, should you need it, using @command{guix
    package} (@pxref{Invoking guix package}).
    
    
    @subsubsection Keyboard Layout
    
    @cindex keyboard layout
    The installation image uses the US qwerty keyboard layout.  If you want
    to change it, you can use the @command{loadkeys} command.  For example,
    the following command selects the Dvorak keyboard layout:
    
    @example
    loadkeys dvorak
    @end example
    
    See the files under @file{/run/current-system/profile/share/keymaps} for
    a list of available keyboard layouts.  Run @command{man loadkeys} for
    more information.
    
    @subsubsection Networking
    
    Run the following command see what your network interfaces are called:
    
    @noindent
    @dots{} or, using the GNU/Linux-specific @command{ip} command:
    
    @example
    ip a
    @end example
    
    
    @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
    
    Wired interfaces have a name starting with @samp{e}; for example, the
    interface corresponding to the first on-board Ethernet controller is
    called @samp{eno1}.  Wireless interfaces have a name starting with
    @samp{w}, like @samp{w1p2s0}.
    
    @table @asis
    @item Wired connection
    To configure a wired network run the following command, substituting
    @var{interface} with the name of the wired interface you want to use.
    
    @example
    ifconfig @var{interface} up
    @end example
    
    @item Wireless connection
    To configure wireless networking, you can create a configuration file
    for the @command{wpa_supplicant} configuration tool (its location is not
    important) using one of the available text editors such as
    @command{zile}:
    
    @example
    zile wpa_supplicant.conf
    @end example
    
    As an example, the following stanza can go to this file and will work
    for many wireless networks, provided you give the actual SSID and
    passphrase for the network you are connecting to:
    
    @example
    network=@{
    
      key_mgmt=WPA-PSK
      psk="the network's secret passphrase"
    @}
    @end example
    
    Start the wireless service and run it in the background with the
    following command (substitute @var{interface} with the name of the
    network interface you want to use):
    
    @example
    wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
    @end example
    
    
    Run @command{man wpa_supplicant} for more information.
    
    @end table
    
    At this point, you need to acquire an IP address.  On a network where IP
    addresses are automatically assigned @i{via} DHCP, you can run:
    
    @example
    
    dhclient -v @var{interface}
    
    Try to ping a server to see if networking is up and running:
    
    @example
    ping -c 3 gnu.org
    @end example
    
    
    Setting up network access is almost always a requirement because the
    image does not contain all the software and tools that may be needed.
    
    
    @subsubsection Disk Partitioning
    
    Unless this has already been done, the next step is to partition, and
    then format the target partition(s).
    
    The installation image includes several partitioning tools, including
    Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
    @command{fdisk}, and @command{cfdisk}.  Run it and set up your disk with
    the partition layout you want:
    
    @example
    cfdisk
    @end example
    
    Once you are done partitioning the target hard disk drive, you have to
    create a file system on the relevant partition(s)@footnote{Currently
    GuixSD pretty much assumes an ext4 file system.  In particular, code
    that reads partition UUIDs and labels only works with ext4.  This will
    be fixed in the future.}.
    
    Preferably, assign partitions a label so that you can easily and
    reliably refer to them in @code{file-system} declarations (@pxref{File
    Systems}).  This is typically done using the @code{-L} option of
    
    @command{mkfs.ext4} and related commands.  So, assuming the target root
    partition lives at @file{/dev/sda1}, a file system with the label
    @code{my-root} can be created with:
    
    @example
    mkfs.ext4 -L my-root /dev/sda1
    @end example
    
    @c FIXME: Uncomment this once GRUB fully supports encrypted roots.
    @c A typical command sequence may be:
    @c
    @c @example
    @c # fdisk /dev/sdX
    @c @dots{} Create partitions etc.@dots{}
    @c # cryptsetup luksFormat /dev/sdX1
    @c # cryptsetup open --type luks /dev/sdX1 my-partition
    @c # mkfs.ext4 -L my-root /dev/mapper/my-partition
    @c @end example
    
    In addition to e2fsprogs, the suite of tools to manipulate
    ext2/ext3/ext4 file systems, the installation image includes
    Cryptsetup/LUKS for disk encryption.
    
    Once that is done, mount the target root partition under @file{/mnt}
    with a command like (again, assuming @file{/dev/sda1} is the root
    partition):
    
    @example
    mount /dev/sda1 /mnt
    @end example
    
    Finally, if you plan to use one or more swap partitions (@pxref{Memory
    Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
    sure to initialize them with @command{mkswap}.  Assuming you have one
    swap partition on @file{/dev/sda2}, you would run:
    
    @example
    mkswap /dev/sda2
    @end example
    
    
    @node Proceeding with the Installation
    @subsection Proceeding with the Installation
    
    With the target partitions ready and the target root mounted on
    @file{/mnt}, we're ready to go.  First, run:
    
    @example
    herd start cow-store /mnt
    @end example
    
    This makes @file{/gnu/store} copy-on-write, such that packages added to it
    during the installation phase are written to the target disk on @file{/mnt}
    rather than kept in memory.  This is necessary because the first phase of
    the @command{guix system init} command (see below) entails downloads or
    builds to @file{/gnu/store} which, initially, is an in-memory file system.
    
    Next, you have to edit a file and
    
    provide the declaration of the operating system to be installed.  To
    that end, the installation system comes with two text editors: GNU nano
    (@pxref{Top,,, nano, GNU nano Manual}), and GNU Zile, an Emacs clone.
    
    We strongly recommend storing that file on the target root file system, say,
    as @file{/mnt/etc/config.scm}.  Failing to do that, you will have lost your
    configuration file once you have rebooted into the newly-installed system.
    
    @xref{Using the Configuration System}, for an overview of the
    configuration file.  The example configurations discussed in that
    section are available under @file{/etc/configuration} in the
    installation image.  Thus, to get started with a system configuration
    providing a graphical display server (a ``desktop'' system), you can run
    something along these lines:
    
    @example
    # mkdir /mnt/etc
    # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
    # zile /mnt/etc/config.scm
    @end example
    
    You should pay attention to what your configuration file contains, and
    in particular:
    
    @itemize
    @item
    Make sure the @code{grub-configuration} form refers to the device you
    want to install GRUB on.
    
    @item
    Be sure that your partition labels match the value of their respective
    @code{device} fields in your @code{file-system} configuration, assuming
    your @code{file-system} configuration sets the value of @code{title} to
    @code{'label}.
    @end itemize
    
    Once you are done preparing the configuration file, the new system must
    be initialized (remember that the target root file system is mounted
    under @file{/mnt}):
    
    
    @example
    guix system init /mnt/etc/config.scm /mnt
    @end example
    
    @noindent
    
    This copies all the necessary files and installs GRUB on
    
    @file{/dev/sdX}, unless you pass the @option{--no-grub} option.  For
    
    more information, @pxref{Invoking guix system}.  This command may trigger
    
    downloads or builds of missing packages, which can take some time.
    
    
    Once that command has completed---and hopefully succeeded!---you can run
    @command{reboot} and boot into the new system.  The @code{root} password
    in the new system is initially empty; other users' passwords need to be
    initialized by running the @command{passwd} command as @code{root},
    unless your configuration specifies otherwise
    (@pxref{user-account-password, user account passwords}).
    
    Join us on @code{#guix} on the Freenode IRC network or on
    
    @file{guix-devel@@gnu.org} to share your experience---good or not so
    good.
    
    
    @node Building the Installation Image
    
    @subsection Building the Installation Image
    
    The installation image described above was built using the @command{guix
    system} command, specifically:
    
    
    @c FIXME: 1G is too much; see <http://bugs.gnu.org/23077>.
    
    guix system disk-image --image-size=1G gnu/system/install.scm
    
    Have a look at @file{gnu/system/install.scm} in the source tree,
    and see also @ref{Invoking guix system} for more information
    
    about the installation image.
    
    
    @node System Configuration
    @section System Configuration
    
    @cindex system configuration
    
    The Guix System Distribution supports a consistent whole-system configuration
    
    mechanism.  By that we mean that all aspects of the global system
    configuration---such as the available system services, timezone and
    locale settings, user accounts---are declared in a single place.  Such
    a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
    
    One of the advantages of putting all the system configuration under the
    control of Guix is that it supports transactional system upgrades, and
    
    makes it possible to roll back to a previous system instantiation,
    
    should something go wrong with the new one (@pxref{Features}).  Another
    
    advantage is that it makes it easy to replicate the exact same configuration
    
    across different machines, or at different points in time, without
    having to resort to additional administration tools layered on top of
    
    the own tools of the system.
    
    @c Yes, we're talking of Puppet, Chef, & co. here.  ↑
    
    This section describes this mechanism.  First we focus on the system
    administrator's viewpoint---explaining how the system is configured and
    instantiated.  Then we show how this mechanism can be extended, for
    instance to support new system services.
    
    @menu
    * Using the Configuration System::  Customizing your GNU system.
    
    * operating-system Reference::  Detail of operating-system declarations.
    
    * File Systems::                Configuring file system mounts.
    
    * Mapped Devices::              Block device extra processing.
    
    * User Accounts::               Specifying user accounts.
    
    * Locales::                     Language and cultural convention settings.
    
    * Services::                    Specifying system services.
    
    * Setuid Programs::             Programs running with root privileges.
    
    * X.509 Certificates::          Authenticating HTTPS servers.
    
    * Name Service Switch::         Configuring libc's name service switch.
    
    * Initial RAM Disk::            Linux-Libre bootstrapping.
    
    * GRUB Configuration::          Configuring the boot loader.
    
    * Invoking guix system::        Instantiating a system configuration.
    
    * Running GuixSD in a VM::      How to run GuixSD in a virtual machine.
    
    * Defining Services::           Adding new service definitions.
    @end menu
    
    @node Using the Configuration System
    @subsection Using the Configuration System
    
    The operating system is configured by providing an
    @code{operating-system} declaration in a file that can then be passed to
    the @command{guix system} command (@pxref{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:
    
    @findex operating-system
    @lisp
    
    @include os-config-bare-bones.texi
    
    This example should be self-describing.  Some of the fields defined
    above, such as @code{host-name} and @code{bootloader}, are mandatory.
    Others, such as @code{packages} and @code{services}, can be omitted, in
    which case they get a default value.
    
    Below we discuss the effect of some of the most important fields
    (@pxref{operating-system Reference}, for details about all the available
    fields), and how to @dfn{instantiate} the operating system using
    @command{guix system}.
    
    @unnumberedsubsubsec Globally-Visible Packages
    
    
    @vindex %base-packages
    
    The @code{packages} field lists packages that will be globally visible
    on the system, for all user accounts---i.e., in every user's @code{PATH}
    environment variable---in addition to the per-user profiles
    (@pxref{Invoking guix package}).  The @var{%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 editor, @command{find}, @command{grep},
    etc.  The example above adds tcpdump to those, taken from the @code{(gnu
    packages admin)} module (@pxref{Package Modules}).
    
    @findex specification->package
    Referring to packages by variable name, like @var{tcpdump} above, has
    the advantage of being unambiguous; it also allows typos and such to be
    diagnosed right away as ``unbound variables''.  The downside is that one
    needs to know which module defines which package, and to augment the
    @code{use-package-modules} line accordingly.  To avoid that, one can use
    the @code{specification->package} procedure of the @code{(gnu packages)}
    module, which returns the best package for a given name or name and
    version:
    
    @lisp
    (use-modules (gnu packages))
    
    (operating-system
      ;; ...
      (packages (append (map specification->package
    
                             '("tcpdump" "htop" "gnupg@@2.0"))
    
                        %base-packages)))
    @end lisp
    
    
    @unnumberedsubsubsec System Services
    
    
    @vindex %base-services
    The @code{services} field lists @dfn{system services} to be made
    available when the system starts (@pxref{Services}).
    The @code{operating-system} declaration above specifies that, in
    addition to the basic services, we want the @command{lshd} secure shell
    
    daemon listening on port 2222 (@pxref{Networking Services,
    @code{lsh-service}}).  Under the hood,
    
    @code{lsh-service} arranges so that @code{lshd} is started with the
    right command-line options, possibly with supporting configuration files
    
    generated as needed (@pxref{Defining Services}).
    
    @cindex customization, of services
    @findex modify-services
    Occasionally, instead of using the base services as is, you will want to
    
    customize them.  To do this, use @code{modify-services} (@pxref{Service
    Reference, @code{modify-services}}) to modify the list.
    
    For example, suppose you want to modify @code{guix-daemon} and Mingetty
    (the console log-in) in the @var{%base-services} list (@pxref{Base
    Services, @code{%base-services}}).  To do that, you can write the
    following in your operating system declaration:
    
    (define %my-services
      ;; My very own list of services.
      (modify-services %base-services
        (guix-service-type config =>
                           (guix-configuration
                            (inherit config)
                            (use-substitutes? #f)
                            (extra-options '("--gc-keep-derivations"))))
        (mingetty-service-type config =>
                               (mingetty-configuration
                                (inherit config)
                                (motd (plain-file "motd" "Howdy!"))))))
    
    (operating-system
      ;; @dots{}
      (services %my-services))
    
    This changes the configuration---i.e., the service parameters---of the
    @code{guix-service-type} instance, and that of all the
    @code{mingetty-service-type} instances in the @var{%base-services} list.
    Observe how this is accomplished: first, we arrange for the original
    configuration to be bound to the identifier @code{config} in the
    @var{body}, and then we write the @var{body} so that it evaluates to the
    desired configuration.  In particular, notice how we use @code{inherit}
    to create a new configuration which has the same values as the old
    configuration, but with a few modifications.
    
    The configuration for a typical ``desktop'' usage, with the X11 display
    
    server, GNOME and Xfce (users can choose which of these desktop
    environments to use at the log-in screen by pressing @kbd{F1}), network
    management, power management, and more, would look like this:
    
    A graphical environment with a choice of lightweight window managers
    instead of full-blown desktop environments would look like this:
    
    @lisp
    @include os-config-lightweight-desktop.texi
    @end lisp
    
    
    @xref{Desktop Services}, for the exact list of services provided by
    
    @var{%desktop-services}.  @xref{X.509 Certificates}, for background
    information about the @code{nss-certs} package that is used here.
    
    Again, @var{%desktop-services} is just a list of service objects.  If
    you want to remove services from there, you can do so using the
    procedures for list filtering (@pxref{SRFI-1 Filtering and
    Partitioning,,, guile, GNU Guile Reference Manual}).  For instance, the
    following expression returns a list that contains all the services in
    @var{%desktop-services} minus the Avahi service:
    
    @example
    (remove (lambda (service)
              (eq? (service-kind service) avahi-service-type))
            %desktop-services)
    @end example
    
    @unnumberedsubsubsec Instantiating the System
    
    Assuming the @code{operating-system} declaration
    is stored in the @file{my-system-config.scm}
    
    file, the @command{guix system reconfigure my-system-config.scm} command
    instantiates that configuration, and makes it the default GRUB boot
    
    entry (@pxref{Invoking guix system}).
    
    
    The normal way to change the system configuration is by updating this
    
    file and re-running @command{guix system reconfigure}.  One should never
    have to touch files in @command{/etc} or to run commands that modify the
    system state such as @command{useradd} or @command{grub-install}.  In
    fact, you must avoid that since that would not only void your warranty
    but also prevent you from rolling back to previous versions of your
    system, should you ever need to.
    
    @cindex roll-back, of the operating system
    Speaking of roll-back, each time you run @command{guix system
    reconfigure}, a new @dfn{generation} of the system is created---without
    modifying or deleting previous generations.  Old system generations get
    an entry in the GRUB boot menu, allowing you to boot them in case
    something went wrong with the latest generation.  Reassuring, no?  The
    @command{guix system list-generations} command lists the system
    generations available on disk.
    
    @unnumberedsubsubsec The Programming Interface
    
    
    At the Scheme level, the bulk of an @code{operating-system} declaration
    is instantiated with the following monadic procedure (@pxref{The Store
    Monad}):
    
    @deffn {Monadic Procedure} operating-system-derivation os
    Return a derivation that builds @var{os}, an @code{operating-system}
    object (@pxref{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 @var{os}.
    @end deffn
    
    This procedure is provided by the @code{(gnu system)} module.  Along
    with @code{(gnu services)} (@pxref{Services}), this module contains the
    guts of GuixSD.  Make sure to visit it!
    
    
    
    @node operating-system Reference
    @subsection @code{operating-system} Reference
    
    This section summarizes all the options available in
    @code{operating-system} declarations (@pxref{Using the Configuration
    System}).
    
    @deftp {Data Type} operating-system
    This is the data type representing an operating system configuration.
    By that, we mean all the global system configuration, not per-user
    configuration (@pxref{Using the Configuration System}).
    
    @table @asis
    @item @code{kernel} (default: @var{linux-libre})
    
    The package object of the operating system kernel to use@footnote{Currently
    
    only the Linux-libre kernel is supported.  In the future, it will be
    possible to use the GNU@tie{}Hurd.}.
    
    
    @item @code{kernel-arguments} (default: @code{'()})
    List of strings or gexps representing additional arguments to pass on
    
    the command-line of the kernel---e.g., @code{("console=ttyS0")}.
    
    @item @code{bootloader}
    
    The system bootloader configuration object.  @xref{GRUB Configuration}.
    
    
    @item @code{initrd} (default: @code{base-initrd})
    A two-argument monadic procedure that returns an initial RAM disk for
    the Linux kernel.  @xref{Initial RAM Disk}.
    
    
    @item @code{firmware} (default: @var{%base-firmware})
    @cindex firmware
    List of firmware packages loadable by the operating system kernel.
    
    The default includes firmware needed for Atheros-based WiFi devices
    
    (Linux-libre module @code{ath9k}).  @xref{Hardware Considerations}, for
    more info on supported hardware.
    
    @item @code{host-name}
    The host name.
    
    @item @code{hosts-file}
    @cindex hosts file
    
    A file-like object (@pxref{G-Expressions, file-like objects}) for use as
    
    @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
    
    Reference Manual}).  The default is a file with entries for
    
    @code{localhost} and @var{host-name}.
    
    @item @code{mapped-devices} (default: @code{'()})
    A list of mapped devices.  @xref{Mapped Devices}.
    
    @item @code{file-systems}
    A list of file systems.  @xref{File Systems}.
    
    @item @code{swap-devices} (default: @code{'()})
    @cindex swap devices
    A list of strings identifying devices to be used for ``swap space''
    (@pxref{Memory Concepts,,, libc, The GNU C Library Reference Manual}).
    For example, @code{'("/dev/sda3")}.
    
    
    @item @code{users} (default: @code{%base-user-accounts})
    
    @itemx @code{groups} (default: @var{%base-groups})
    List of user accounts and groups.  @xref{User Accounts}.
    
    @item @code{skeletons} (default: @code{(default-skeletons)})
    
    A list target file name/file-like object tuples (@pxref{G-Expressions,
    file-like objects}).  These are the skeleton files that will be added to
    the home directory of newly-created user accounts.
    
    
    For instance, a valid value may look like this:
    
    @example
    
    `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
      (".guile" ,(plain-file "guile"
                             "(use-modules (ice-9 readline))
                              (activate-readline)")))
    
    @end example
    
    @item @code{issue} (default: @var{%default-issue})
    A string denoting the contents of the @file{/etc/issue} file, which is
    
    displayed when users log in on a text console.
    
    
    @item @code{packages} (default: @var{%base-packages})
    The set of packages installed in the global profile, which is accessible
    at @file{/run/current-system/profile}.
    
    
    The default set includes core utilities and it is good practice to
    
    install non-core utilities in user profiles (@pxref{Invoking guix
    package}).
    
    @item @code{timezone}
    A timezone identifying string---e.g., @code{"Europe/Paris"}.
    
    
    You can run the @command{tzselect} command to find out which timezone
    string corresponds to your region.  Choosing an invalid timezone name
    causes @command{guix system} to fail.
    
    
    @item @code{locale} (default: @code{"en_US.utf8"})
    The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
    Library Reference Manual}).  @xref{Locales}, for more information.
    
    @item @code{locale-definitions} (default: @var{%default-locale-definitions})
    The list of locale definitions to be compiled and that may be used at
    run time.  @xref{Locales}.
    
    @item @code{locale-libcs} (default: @code{(list @var{glibc})})
    The list of GNU@tie{}libc packages whose locale data and tools are used
    to build the locale definitions.  @xref{Locales}, for compatibility
    considerations that justify this option.
    
    
    @item @code{name-service-switch} (default: @var{%default-nss})
    
    Configuration of the libc name service switch (NSS)---a
    
    @code{<name-service-switch>} object.  @xref{Name Service Switch}, for
    details.
    
    
    @item @code{services} (default: @var{%base-services})
    
    A list of service objects denoting system services.  @xref{Services}.
    
    
    @item @code{pam-services} (default: @code{(base-pam-services)})
    @cindex PAM
    @cindex pluggable authentication modules
    Linux @dfn{pluggable authentication module} (PAM) services.
    @c FIXME: Add xref to PAM services section.
    
    @item @code{setuid-programs} (default: @var{%setuid-programs})
    List of string-valued G-expressions denoting setuid programs.
    @xref{Setuid Programs}.
    
    
    @item @code{sudoers-file} (default: @var{%sudoers-specification})
    @cindex sudoers file
    
    The contents of the @file{/etc/sudoers} file as a file-like object
    (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
    
    
    This file specifies which users can use the @command{sudo} command, what
    they are allowed to do, and what privileges they may gain.  The default
    is that only @code{root} and members of the @code{wheel} group may use
    @code{sudo}.
    
    @end table
    @end deftp
    
    
    @node File Systems
    @subsection File Systems
    
    The list of file systems to be mounted is specified in the
    
    @code{file-systems} field of the operating system declaration
    
    (@pxref{Using the Configuration System}).  Each file system is declared
    using the @code{file-system} form, like this:
    
    (file-system
      (mount-point "/home")
      (device "/dev/sda3")
      (type "ext4"))
    
    As usual, some of the fields are mandatory---those shown in the example
    above---while others can be omitted.  These are described below.
    
    @deftp {Data Type} file-system
    Objects of this type represent file systems to be mounted.  They
    contain the following members:
    
    @table @asis
    @item @code{type}
    This is a string specifying the type of the file system---e.g.,
    @code{"ext4"}.
    
    @item @code{mount-point}
    This designates the place where the file system is to be mounted.
    
    @item @code{device}
    This names the ``source'' of the file system.  By default it is the name
    of a node under @file{/dev}, but its meaning depends on the @code{title}
    field described below.
    
    @item @code{title} (default: @code{'device})
    This is a symbol that specifies how the @code{device} field is to be
    interpreted.
    
    When it is the symbol @code{device}, then the @code{device} field is
    interpreted as a file name; when it is @code{label}, then @code{device}
    is interpreted as a partition label name; when it is @code{uuid},
    @code{device} is interpreted as a partition unique identifier (UUID).
    
    UUIDs may be converted from their string representation (as shown by the
    
    @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
    @code{uuid} form expects 16-byte UUIDs as defined in
    @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}.  This is the
    form of UUID used by the ext2 family of file systems and others, but it
    is different from ``UUIDs'' found in FAT file systems, for instance.},
    like this:
    
    
    @example
    (file-system
      (mount-point "/home")
      (type "ext4")
      (title 'uuid)
      (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
    @end example
    
    
    The @code{label} and @code{uuid} options offer a way to refer to disk
    
    partitions without having to hard-code their actual device
    name@footnote{Note that, while it is tempting to use
    @file{/dev/disk/by-uuid} and similar device names to achieve the same
    result, this is not recommended: These special device nodes are created
    by the udev daemon and may be unavailable at the time the device is
    mounted.}.
    
    However, when the source of a file system is a mapped device (@pxref{Mapped
    
    Devices}), its @code{device} field @emph{must} refer to the mapped
    device name---e.g., @file{/dev/mapper/root-partition}---and consequently
    @code{title} must be set to @code{'device}.  This is required so that
    the system knows that mounting the file system depends on having the
    corresponding device mapping established.
    
    
    @item @code{flags} (default: @code{'()})
    This is a list of symbols denoting mount flags.  Recognized flags
    
    include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
    access to special files), @code{no-suid} (ignore setuid and setgid
    bits), and @code{no-exec} (disallow program execution.)
    
    @item @code{options} (default: @code{#f})
    This is either @code{#f}, or a string denoting mount options.
    
    @item @code{mount?} (default: @code{#t})
    This value indicates whether to automatically mount the file system when
    the system is brought up.  When set to @code{#f}, the file system gets
    an entry in @file{/etc/fstab} (read by the @command{mount} command) but
    is not automatically mounted.
    
    
    @item @code{needed-for-boot?} (default: @code{#f})
    This Boolean value indicates whether the file system is needed when
    booting.  If that is true, then the file system is mounted when the
    initial RAM disk (initrd) is loaded.  This is always the case, for
    instance, for the root file system.
    
    @item @code{check?} (default: @code{#t})
    This Boolean indicates whether the file system needs to be checked for
    errors before being mounted.
    
    @item @code{create-mount-point?} (default: @code{#f})
    When true, the mount point is created if it does not exist yet.
    
    
    @item @code{dependencies} (default: @code{'()})
    This is a list of @code{<file-system>} objects representing file systems
    that must be mounted before (and unmounted after) this one.
    
    As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
    a dependency of @file{/sys/fs/cgroup/cpu} and
    @file{/sys/fs/cgroup/memory}.
    
    
    @end table
    @end deftp
    
    The @code{(gnu system file-systems)} exports the following useful
    variables.
    
    @defvr {Scheme Variable} %base-file-systems
    These are essential file systems that are required on normal systems,
    
    such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
    
    below.)  Operating system declarations should always contain at least
    these.
    
    @defvr {Scheme Variable} %pseudo-terminal-file-system
    This is the file system to be mounted as @file{/dev/pts}.  It supports
    @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
    functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
    Manual}).  Pseudo-terminals are used by terminal emulators such as
    @command{xterm}.
    @end defvr
    
    
    Ludovic Courtès's avatar
    Ludovic Courtès committed
    @defvr {Scheme Variable} %shared-memory-file-system
    This file system is mounted as @file{/dev/shm} and is used to support
    memory sharing across processes (@pxref{Memory-mapped I/O,
    @code{shm_open},, libc, The GNU C Library Reference Manual}).
    @end defvr
    
    
    @defvr {Scheme Variable} %immutable-store
    This file system performs a read-only ``bind mount'' of
    @file{/gnu/store}, making it read-only for all the users including
    @code{root}.  This prevents against accidental modification by software
    running as @code{root} or by system administrators.
    
    The daemon itself is still able to write to the store: it remounts it
    read-write in its own ``name space.''
    @end defvr
    
    
    @defvr {Scheme Variable} %binary-format-file-system
    The @code{binfmt_misc} file system, which allows handling of arbitrary
    executable file types to be delegated to user space.  This requires the
    @code{binfmt.ko} kernel module to be loaded.
    @end defvr
    
    @defvr {Scheme Variable} %fuse-control-file-system
    The @code{fusectl} file system, which allows unprivileged users to mount
    and unmount user-space FUSE file systems.  This requires the
    @code{fuse.ko} kernel module to be loaded.
    @end defvr
    
    
    @node Mapped Devices
    @subsection Mapped Devices
    
    @cindex device mapping
    @cindex mapped devices
    The Linux kernel has a notion of @dfn{device mapping}: a block device,
    such as a hard disk partition, can be @dfn{mapped} into another device,
    with additional processing over the data that flows through
    it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
    concept of a ``mapped device'' and that of a file system: both boil down
    to @emph{translating} input/output operations made on a file to
    operations on its backing store.  Thus, the Hurd implements mapped
    devices, like file systems, using the generic @dfn{translator} mechanism
    (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}.  A
    typical example is encryption device mapping: all writes to the mapped
    device are encrypted, and all reads are deciphered, transparently.
    
    Mapped devices are declared using the @code{mapped-device} form:
    
    @example
    (mapped-device
      (source "/dev/sda3")
      (target "home")
      (type luks-device-mapping))
    @end example
    
    
    Or, better yet, like this:
    
    @example
    (mapped-device
      (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
      (target "home")
      (type luks-device-mapping))
    @end example
    
    
    @cindex disk encryption
    @cindex LUKS
    This example specifies a mapping from @file{/dev/sda3} to
    @file{/dev/mapper/home} using LUKS---the
    @url{http://code.google.com/p/cryptsetup,Linux Unified Key Setup}, a
    
    standard mechanism for disk encryption.  In the second example, the UUID
    (unique identifier) is the LUKS UUID returned for the device by a
    command like:
    
    @example
    cryptsetup luksUUID /dev/sdx9
    @end example
    
    The @file{/dev/mapper/home}
    
    device can then be used as the @code{device} of a @code{file-system}
    declaration (@pxref{File Systems}).  The @code{mapped-device} form is
    detailed below.
    
    @deftp {Data Type} mapped-device
    Objects of this type represent device mappings that will be made when
    the system boots up.
    
    
    This string specifies the name of the block device to be mapped, such as
    @code{"/dev/sda3"}.
    
    
    This string specifies the name of the mapping to be established.  For
    example, specifying @code{"my-partition"} will lead to the creation of
    the @code{"/dev/mapper/my-partition"} device.
    
    
    This must be a @code{mapped-device-kind} object, which specifies how
    @var{source} is mapped to @var{target}.
    @end table
    @end deftp
    
    @defvr {Scheme Variable} luks-device-mapping
    This defines LUKS block device encryption using the @command{cryptsetup}
    
    command from the package with the same name.  It relies on the
    
    @code{dm-crypt} Linux kernel module.
    @end defvr
    
    
    @node User Accounts
    @subsection User Accounts
    
    User accounts and groups are entirely managed through the
    @code{operating-system} declaration.  They are specified with the
    @code{user-account} and @code{user-group} forms:
    
    @example
    (user-account
      (name "alice")
      (group "users")
    
      (supplementary-groups '("wheel"   ;allow use of sudo, etc.
                              "audio"   ;sound card
                              "video"   ;video devices such as webcams
                              "cdrom")) ;the good ol' CD-ROM
    
      (comment "Bob's sister")
      (home-directory "/home/alice"))
    @end example
    
    When booting or upon completion of @command{guix system reconfigure},
    the system ensures that only the user accounts and groups specified in
    the @code{operating-system} declaration exist, and with the specified
    properties.  Thus, account or group creations or modifications made by
    directly invoking commands such as @command{useradd} are lost upon
    reconfiguration or reboot.  This ensures that the system remains exactly
    as declared.
    
    
    @deftp {Data Type} user-account
    Objects of this type represent user accounts.  The following members may
    be specified:
    
    @table @asis
    @item @code{name}
    The name of the user account.
    
    @item @code{group}
    This is the name (a string) or identifier (a number) of the user group
    this account belongs to.
    
    @item @code{supplementary-groups} (default: @code{'()})
    Optionally, this can be defined as a list of group names that this
    account belongs to.
    
    @item @code{uid} (default: @code{#f})
    This is the user ID for this account (a number), or @code{#f}.  In the
    latter case, a number is automatically chosen by the system when the
    account is created.
    
    @item @code{comment} (default: @code{""})
    
    A comment about the account, such as the account owner's full name.
    
    @item @code{home-directory}
    This is the name of the home directory for the account.
    
    @item @code{shell} (default: Bash)
    This is a G-expression denoting the file name of a program to be used as
    the shell (@pxref{G-Expressions}).
    
    @item @code{system?} (default: @code{#f})
    This Boolean value indicates whether the account is a ``system''
    account.  System accounts are sometimes treated specially; for instance,
    graphical login managers do not list them.
    
    @anchor{user-account-password}
    
    @item @code{password} (default: @code{#f})
    
    You would normally leave this field to @code{#f}, initialize user
    passwords as @code{root} with the @command{passwd} command, and then let
    
    users change it with @command{passwd}.  Passwords set with
    @command{passwd} are of course preserved across reboot and
    reconfiguration.
    
    
    If you @emph{do} want to have a preset password for an account, then
    this field must contain the encrypted password, as a string.
    
    @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
    on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
    
    Manual}, for information on Guile's @code{crypt} procedure.
    
    @end table
    @end deftp
    
    User group declarations are even simpler:
    
    @example
    (user-group (name "students"))
    @end example
    
    @deftp {Data Type} user-group
    This type is for, well, user groups.  There are just a few fields:
    
    @table @asis
    @item @code{name}
    
    The name of the group.
    
    @item @code{id} (default: @code{#f})
    The group identifier (a number).  If @code{#f}, a new number is
    automatically allocated when the group is created.
    
    @item @code{system?} (default: @code{#f})
    This Boolean value indicates whether the group is a ``system'' group.
    System groups have low numerical IDs.
    
    
    @item @code{password} (default: @code{#f})
    What, user groups can have a password?  Well, apparently yes.  Unless
    
    @code{#f}, this field specifies the password of the group.
    
    @end table
    @end deftp
    
    For convenience, a variable lists all the basic user groups one may
    expect:
    
    @defvr {Scheme Variable} %base-groups
    This is the list of basic user groups that users and/or packages expect
    to be present on the system.  This includes groups such as ``root'',
    ``wheel'', and ``users'', as well as groups used to control access to
    specific devices such as ``audio'', ``disk'', and ``cdrom''.
    @end defvr
    
    @defvr {Scheme Variable} %base-user-accounts
    This is the list of basic system accounts that programs may expect to
    find on a GNU/Linux system, such as the ``nobody'' account.
    
    Note that the ``root'' account is not included here.  It is a
    special-case and is automatically added whether or not it is specified.
    @end defvr