Skip to content
Snippets Groups Projects
guix.texi 291 KiB
Newer Older
  • Learn to ignore specific revisions
  • 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.
    
    @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
    Emacs to those, taken from the @code{(gnu packages emacs)} module
    (@pxref{Package Modules}).
    
    @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, and allowing remote @code{root} logins
    (@pxref{Invoking lshd,,, lsh, GNU lsh Manual}).  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}).  @xref{operating-system
    Reference}, for details about the available @code{operating-system}
    fields.
    
    The configuration for a typical ``desktop'' usage, with the X11 display
    server, a desktop environment, network management, an SSH server, and
    more, would look like this:
    
    @lisp
    @include os-config-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.
    
    Assuming the above snippet 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's configuration is by updating this file and re-running the
    @command{guix system} command.
    
    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
    
    @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 kernel's command-line---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}.)
    
    
    @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 monadic list of pairs of target file name and files.  These are the
    files that will be used as skeletons as new accounts are created.
    
    For instance, a valid value may look like this:
    
    @example
    (mlet %store-monad ((bashrc (text-file "bashrc" "\
         export PATH=$HOME/.guix-profile/bin")))
      (return `((".bashrc" ,bashrc))))
    @end example
    
    @item @code{issue} (default: @var{%default-issue})
    A string denoting the contents of the @file{/etc/issue} file, which is
    what 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, but 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"}.
    
    
    @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{name-service-switch} (default: @var{%default-nss})
    Configuration of libc's 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 monadic values 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's 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, 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 a file system's source 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{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
    
    @noindent
    @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.  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 same-named package.  This 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's owner 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 group's name.
    
    @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 group's password.
    
    @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
    
    
    @node Locales
    @subsection Locales
    
    @cindex locale
    A @dfn{locale} defines cultural conventions for a particular language
    and region of the world (@pxref{Locales,,, libc, The GNU C Library
    Reference Manual}).  Each locale has a name that typically has the form
    
    @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
    
    @code{fr_LU.utf8} designates the locale for the French language, with
    cultural conventions from Luxembourg, and using the UTF-8 encoding.
    
    @cindex locale definition
    Usually, you will want to specify the default locale for the machine
    using the @code{locale} field of the @code{operating-system} declaration
    (@pxref{operating-system Reference, @code{locale}}).
    
    That locale must be among the @dfn{locale definitions} that are known to
    the system---and these are specified in the @code{locale-definitions}
    slot of @code{operating-system}.  The default value includes locale
    definition for some widely used locales, but not for all the available
    locales, in order to save space.
    
    If the locale specified in the @code{locale} field is not among the
    definitions listed in @code{locale-definitions}, @command{guix system}
    raises an error.  In that case, you should add the locale definition to
    the @code{locale-definitions} field.  For instance, to add the North
    Frisian locale for Germany, the value of that field may be:
    
    @example
    (cons (locale-definition
            (name "fy_DE.utf8") (source "fy_DE"))
          %default-locale-definitions)
    @end example
    
    Likewise, to save space, one might want @code{locale-definitions} to
    list only the locales that are actually used, as in:
    
    @example
    (list (locale-definition
            (name "ja_JP.eucjp") (source "ja_JP")
            (charset "EUC-JP")))
    @end example
    
    
    @vindex LOCPATH
    The compiled locale definitions are available at
    @file{/run/current-system/locale}, which is the default location where
    the GNU@tie{}libc looks for locale data.  This can be overridden using
    the @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
    @code{LOCPATH} and locale packages}).
    
    
    The @code{locale-definition} form is provided by the @code{(gnu system
    locale)} module.  Details are given below.
    
    @deftp {Data Type} locale-definition
    This is the data type of a locale definition.
    
    @table @asis
    
    @item @code{name}
    The name of the locale.  @xref{Locale Names,,, libc, The GNU C Library
    Reference Manual}, for more information on locale names.
    
    @item @code{source}
    The name of the source for that locale.  This is typically the
    @code{@var{language}_@var{territory}} part of the locale name.
    
    @item @code{charset} (default: @code{"UTF-8"})
    The ``character set'' or ``code set'' for that locale,
    @uref{http://www.iana.org/assignments/character-sets, as defined by
    IANA}.
    
    @end table
    @end deftp
    
    @defvr {Scheme Variable} %default-locale-definitions
    
    An arbitrary list of commonly used UTF-8 locales, used as the default
    value of the @code{locale-definitions} field of @code{operating-system}
    
    
    @cindex locale name
    @cindex normalized codeset in locale names
    These locale definitions use the @dfn{normalized codeset} for the part
    that follows the dot in the name (@pxref{Using gettextized software,
    normalized codeset,, libc, The GNU C Library Reference Manual}).  So for
    instance it has @code{uk_UA.utf8} but @emph{not}, say,
    @code{uk_UA.UTF-8}.
    
    @node Services
    @subsection Services
    
    @cindex system services
    An important part of preparing an @code{operating-system} declaration is
    listing @dfn{system services} and their configuration (@pxref{Using the
    Configuration System}).  System services are typically daemons launched
    when the system boots, or other actions needed at that time---e.g.,
    
    configuring network access.
    
    Services are managed by GNU@tie{}dmd (@pxref{Introduction,,, dmd, GNU
    dmd Manual}).  On a running system, the @command{deco} command allows
    you to list the available services, show their status, start and stop
    them, or do other specific operations (@pxref{Jump Start,,, dmd, GNU dmd
    Manual}).  For example:
    
    @example
    # deco status dmd
    @end example
    
    The above command, run as @code{root}, lists the currently defined
    services.  The @command{deco doc} command shows a synopsis of the given
    service:
    
    @example
    # deco doc nscd
    Run libc's name service cache daemon (nscd).
    @end example
    
    The @command{start}, @command{stop}, and @command{restart} sub-commands
    have the effect you would expect.  For instance, the commands below stop
    the nscd service and restart the Xorg display server:
    
    @example
    # deco stop nscd
    Service nscd has been stopped.
    # deco restart xorg-server
    Service xorg-server has been stopped.
    Service xorg-server has been started.
    @end example
    
    The following sections document the available services, starting with
    
    the core services, that may be used in an @code{operating-system}
    declaration.
    
    @menu
    * Base Services::               Essential system services.
    * Networking Services::         Network setup, SSH daemon, etc.
    * X Window::                    Graphical display.
    
    * Desktop Services::            D-Bus and desktop services.
    
    * Database Services::           SQL databases.
    
    * Web Services::                Web servers.
    
    Alex Kost's avatar
    Alex Kost committed
    * Various Services::            Other services.
    
    @node Base Services
    @subsubsection Base Services
    
    The @code{(gnu services base)} module provides definitions for the basic
    services that one expects from the system.  The services exported by
    this module are listed below.
    
    @defvr {Scheme Variable} %base-services
    This variable contains a list of basic services@footnote{Technically,
    this is a list of monadic services.  @xref{The Store Monad}.} one would
    expect from the system: a login service (mingetty) on each tty, syslogd,
    libc's name service cache daemon (nscd), the udev device manager, and
    more.
    
    This is the default value of the @code{services} field of
    @code{operating-system} declarations.  Usually, when customizing a
    system, you will want to append services to @var{%base-services}, like
    this:
    
    Alex Kost's avatar
    Alex Kost committed
    (cons* (avahi-service) (lsh-service) %base-services)
    
    @end example
    @end defvr
    
    @deffn {Monadic Procedure} host-name-service @var{name}
    Return a service that sets the host name to @var{name}.
    @end deffn
    
    @deffn {Monadic Procedure} mingetty-service @var{tty} [#:motd] @
           [#:auto-login #f] [#:login-program] [#:login-pause? #f] @
           [#:allow-empty-passwords? #f]
    Return a service to run mingetty on @var{tty}.
    
    When @var{allow-empty-passwords?} is true, allow empty log-in password.  When
    @var{auto-login} is true, it must be a user name under which to log-in
    automatically.  @var{login-pause?} can be set to @code{#t} in conjunction with
    @var{auto-login}, in which case the user will have to press a key before the
    login shell is launched.
    
    When true, @var{login-program} is a gexp or a monadic gexp denoting the name
    
    of the log-in program (the default is the @code{login} program from the Shadow
    tool suite.)
    
    @var{motd} is a monadic value containing a text file to use as
    the ``message of the day''.
    @end deffn
    
    @cindex name service cache daemon
    @cindex nscd
    
    @deffn {Monadic Procedure} nscd-service [@var{config}] [#:glibc glibc] @
                    [#:name-services '()]
    Return a service that runs libc's name service cache daemon (nscd) with
    the given @var{config}---an @code{<nscd-configuration>} object.
    Optionally, @code{#:name-services} is a list of packages that provide
    
    name service switch (NSS) modules needed by nscd.  @xref{Name Service
    Switch}, for an example.
    
    @defvr {Scheme Variable} %nscd-default-configuration
    This is the default @code{<nscd-configuration>} value (see below) used
    by @code{nscd-service}.  This uses the caches defined by
    @var{%nscd-default-caches}; see below.
    @end defvr
    
    @deftp {Data Type} nscd-configuration
    This is the type representing the name service cache daemon (nscd)
    configuration.
    
    @table @asis
    
    @item @code{log-file} (default: @code{"/var/log/nscd.log"})
    Name of nscd's log file.  This is where debugging output goes when
    @code{debug-level} is strictly positive.
    
    @item @code{debug-level} (default: @code{0})
    Integer denoting the debugging levels.  Higher numbers mean more
    debugging output is logged.
    
    @item @code{caches} (default: @var{%nscd-default-caches})
    List of @code{<nscd-cache>} objects denoting things to be cached; see
    below.
    
    @end table
    @end deftp
    
    @deftp {Data Type} nscd-cache
    Data type representing a cache database of nscd and its parameters.
    
    @table @asis
    
    @item @code{database}
    This is a symbol representing the name of the database to be cached.
    Valid values are @code{passwd}, @code{group}, @code{hosts}, and
    @code{services}, which designate the corresponding NSS database
    (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
    
    @item @code{positive-time-to-live}
    @itemx @code{negative-time-to-live} (default: @code{20})
    A number representing the number of seconds during which a positive or
    negative lookup result remains in cache.
    
    @item @code{check-files?} (default: @code{#t})
    Whether to check for updates of the files corresponding to
    @var{database}.
    
    For instance, when @var{database} is @code{hosts}, setting this flag
    instructs nscd to check for updates in @file{/etc/hosts} and to take
    them into account.
    
    @item @code{persistent?} (default: @code{#t})
    Whether the cache should be stored persistently on disk.
    
    @item @code{shared?} (default: @code{#t})
    Whether the cache should be shared among users.
    
    @item @code{max-database-size} (default: 32@tie{}MiB)
    Maximum size in bytes of the database cache.
    
    @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
    @c settings, so leave them out.
    
    @end table
    @end deftp
    
    @defvr {Scheme Variable} %nscd-default-caches
    List of @code{<nscd-cache>} objects used by default by
    @code{nscd-configuration} (see above.)
    
    It enables persistent and aggressive caching of service and host name
    lookups.  The latter provides better host name lookup performance,
    resilience in the face of unreliable name servers, and also better
    privacy---often the result of host name lookups is in local cache, so
    external name servers do not even need to be queried.
    @end defvr
    
    
    
    @deffn {Monadic Procedure} syslog-service [#:config-file #f]
    Return a service that runs @code{syslogd}.  If configuration file name
    @var{config-file} is not specified, use some reasonable default
    
    @deffn {Monadic Procedure} guix-service [#:guix guix] @
           [#:builder-group "guixbuild"] [#:build-accounts 10] @
    
           [#:authorize-hydra-key? #t] [#:use-substitutes? #t] @
    
           [#:extra-options '()]
    Return a service that runs the build daemon from @var{guix}, and has
    @var{build-accounts} user accounts available under @var{builder-group}.
    
    When @var{authorize-hydra-key?} is true, the @code{hydra.gnu.org} public key
    provided by @var{guix} is authorized upon activation, meaning that substitutes
    from @code{hydra.gnu.org} are used by default.
    
    If @var{use-substitutes?} is false, the daemon is run with
    @option{--no-substitutes} (@pxref{Invoking guix-daemon,
    @option{--no-substitutes}}).
    
    Finally, @var{extra-options} is a list of additional command-line options
    passed to @command{guix-daemon}.
    @end deffn
    
    @deffn {Monadic Procedure} udev-service [#:udev udev]
    Run @var{udev}, which populates the @file{/dev} directory dynamically.
    @end deffn
    
    @deffn {Monadic Procedure} console-keymap-service @var{file}
    Return a service to load console keymap from @var{file} using
    @command{loadkeys} command.
    @end deffn
    
    
    @node Networking Services
    @subsubsection Networking Services
    
    Alex Kost's avatar
    Alex Kost committed
    The @code{(gnu services networking)} module provides services to configure
    
    the network interface.
    
    @cindex DHCP, networking service
    @deffn {Monadic Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
    Return a service that runs @var{dhcp}, a Dynamic Host Configuration
    Protocol (DHCP) client, on all the non-loopback network interfaces.
    @end deffn
    
    
    @deffn {Monadic Procedure} static-networking-service @var{interface} @var{ip} @
           [#:gateway #f] [#:name-services @code{'()}]
    Return a service that starts @var{interface} with address @var{ip}.  If
    @var{gateway} is true, it must be a string specifying the default network
    gateway.
    @end deffn
    
    @cindex wicd
    @deffn {Monadic Procedure} wicd-service [#:wicd @var{wicd}]
    Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a
    network manager that aims to simplify wired and wireless networking.
    @end deffn
    
    
    @deffn {Monadic Procedure} ntp-service [#:ntp @var{ntp}] @
      [#:name-service @var{%ntp-servers}]
    Return a service that runs the daemon from @var{ntp}, the
    @uref{http://www.ntp.org, Network Time Protocol package}.  The daemon will
    keep the system clock synchronized with that of @var{servers}.
    @end deffn
    
    @defvr {Scheme Variable} %ntp-servers
    List of host names used as the default NTP servers.
    @end defvr
    
    
    @deffn {Monadic Procedure} tor-service [#:tor tor]
    Return a service to run the @uref{https://torproject.org,Tor} daemon.
    
    The daemon runs with the default settings (in particular the default exit
    policy) as the @code{tor} unprivileged user.
    @end deffn
    
    @deffn {Monadic Procedure} bitlbee-service [#:bitlbee bitlbee] @
             [#:interface "127.0.0.1"] [#:port 6667] @
             [#:extra-settings ""]
    Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that
    acts as a gateway between IRC and chat networks.
    
    The daemon will listen to the interface corresponding to the IP address
    specified in @var{interface}, on @var{port}.  @code{127.0.0.1} means that only
    local clients can connect, whereas @code{0.0.0.0} means that connections can
    come from any networking interface.
    
    In addition, @var{extra-settings} specifies a string to append to the
    configuration file.
    @end deffn
    
    
    Furthermore, @code{(gnu services ssh)} provides the following service.
    
    @deffn {Monadic Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
    
           [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
    
           [#:allow-empty-passwords? #f] [#:root-login? #f] @
           [#:syslog-output? #t] [#:x11-forwarding? #t] @
           [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
    
           [#:public-key-authentication? #t] [#:initialize? #t]
    
    Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
    @var{host-key} must designate a file containing the host key, and readable
    only by root.
    
    When @var{daemonic?} is true, @command{lshd} will detach from the
    controlling terminal and log its output to syslogd, unless one sets
    @var{syslog-output?} to false.  Obviously, it also makes lsh-service
    depend on existence of syslogd service.  When @var{pid-file?} is true,
    @command{lshd} writes its PID to the file called @var{pid-file}.
    
    
    When @var{initialize?} is true, automatically create the seed and host key
    upon service activation if they do not exist yet.  This may take long and
    require interaction.
    
    When @var{initialize?} is false, it is up to the user to initialize the
    randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
    a key pair with the private key stored in file @var{host-key} (@pxref{lshd
    basics,,, lsh, LSH Manual}).
    
    
    When @var{interfaces} is empty, lshd listens for connections on all the
    network interfaces; otherwise, @var{interfaces} must be a list of host names
    or addresses.
    
    @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
    passwords, and @var{root-login?} specifies whether to accept log-ins as
    
    The other options should be self-descriptive.
    @end deffn
    
    @defvr {Scheme Variable} %facebook-host-aliases
    This variable contains a string for use in @file{/etc/hosts}
    (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}).  Each
    line contains a entry that maps a known server name of the Facebook
    on-line service---e.g., @code{www.facebook.com}---to the local
    host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
    
    This variable is typically used in the @code{hosts-file} field of an
    
    @code{operating-system} declaration (@pxref{operating-system Reference,
    @file{/etc/hosts}}):
    
    
    @example
    (use-modules (gnu) (guix))
    
    (operating-system
      (host-name "mymachine")
      ;; ...
      (hosts-file
        ;; Create a /etc/hosts file with aliases for "localhost"
        ;; and "mymachine", as well as for Facebook servers.
    
        (plain-file "hosts"
                    (string-append (local-host-aliases host-name)
                                   %facebook-host-aliases))))
    
    @end example
    
    This mechanism can prevent programs running locally, such as Web
    browsers, from accessing Facebook.
    @end defvr
    
    
    The @code{(gnu services avahi)} provides the following definition.
    
    @deffn {Monadic Procedure} avahi-service [#:avahi @var{avahi}] @
              [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
              [#:ipv6? #t] [#:wide-area? #f] @
              [#:domains-to-browse '()]
    Return a service that runs @command{avahi-daemon}, a system-wide
    mDNS/DNS-SD responder that allows for service discovery and
    "zero-configuration" host name lookups (see @uref{http://avahi.org/}).
    
    If @var{host-name} is different from @code{#f}, use that as the host name to
    publish for this machine; otherwise, use the machine's actual host name.
    
    When @var{publish?} is true, publishing of host names and services is allowed;
    in particular, avahi-daemon will publish the machine's host name and IP
    address via mDNS on the local network.
    
    When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
    
    Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
    sockets.
    @end deffn
    
    
    
    @node X Window
    @subsubsection X Window
    
    Support for the X Window graphical display system---specifically
    Xorg---is provided by the @code{(gnu services xorg)} module.  Note that
    there is no @code{xorg-service} procedure.  Instead, the X server is
    started by the @dfn{login manager}, currently SLiM.