Skip to content
Snippets Groups Projects
guix.texi 523 KiB
Newer Older
  • Learn to ignore specific revisions
  • 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
    
    
    @anchor{syslog-configuration-type}
    
    @cindex syslog
    @cindex logging
    
    @deftp {Data Type} syslog-configuration
    This data type represents the configuration of the syslog daemon.
    
    @table @asis
    @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
    The syslog daemon to use.
    
    @item @code{config-file} (default: @code{%default-syslog.conf})
    The syslog configuration file to use.
    
    @end table
    @end deftp
    
    @anchor{syslog-service}
    
    @cindex syslog
    
    @deffn {Scheme Procedure} syslog-service @var{config}
    Return a service that runs a syslog daemon according to @var{config}.
    
    
    @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
    information on the configuration file syntax.
    
    @anchor{guix-configuration-type}
    @deftp {Data Type} guix-configuration
    This data type represents the configuration of the Guix build daemon.
    @xref{Invoking guix-daemon}, for more information.
    
    @table @asis
    @item @code{guix} (default: @var{guix})
    The Guix package to use.
    
    @item @code{build-group} (default: @code{"guixbuild"})
    Name of the group for build user accounts.
    
    @item @code{build-accounts} (default: @code{10})
    Number of build user accounts to create.
    
    @item @code{authorize-key?} (default: @code{#t})
    
    @cindex substitutes, authorization thereof
    
    Whether to authorize the substitute keys listed in
    @code{authorized-keys}---by default that of @code{hydra.gnu.org}
    
    (@pxref{Substitutes}).
    
    
    @vindex %default-authorized-guix-keys
    @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
    The list of authorized key files for archive imports, as a list of
    string-valued gexps (@pxref{Invoking guix archive}).  By default, it
    contains that of @code{hydra.gnu.org} (@pxref{Substitutes}).
    
    
    @item @code{use-substitutes?} (default: @code{#t})
    Whether to use substitutes.
    
    
    @item @code{substitute-urls} (default: @var{%default-substitute-urls})
    The list of URLs where to look for substitutes by default.
    
    
    @item @code{extra-options} (default: @code{'()})
    List of extra command-line options for @command{guix-daemon}.
    
    @item @code{lsof} (default: @var{lsof})
    @itemx @code{lsh} (default: @var{lsh})
    The lsof and lsh packages to use.
    
    @end table
    @end deftp
    
    @deffn {Scheme Procedure} guix-service @var{config}
    Return a service that runs the Guix build daemon according to
    @var{config}.
    
    @deffn {Scheme Procedure} udev-service [#:udev udev]
    
    Run @var{udev}, which populates the @file{/dev} directory dynamically.
    @end deffn
    
    @deffn {Scheme Procedure} urandom-seed-service @var{#f}
    Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
    when rebooting.
    @end deffn
    
    @defvr {Scheme Variable} %random-seed-file
    This is the name of the file where some random bytes are saved by
    @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
    It defaults to @file{/var/lib/random-seed}.
    @end defvr
    
    
    @cindex keymap
    @cindex keyboard
    
    @deffn {Scheme Procedure} console-keymap-service @var{files} ...
    
    Return a service to load console keymaps from @var{files} using
    @command{loadkeys} command.  Most likely, you want to load some default
    keymap, which can be done like this:
    
    @example
    (console-keymap-service "dvorak")
    @end example
    
    Or, for example, for a Swedish keyboard, you may need to combine
    the following keymaps:
    @example
    (console-keymap-service "se-lat6" "se-fi-lat6")
    @end example
    
    Also you can specify a full file name (or file names) of your keymap(s).
    See @code{man loadkeys} for details.
    
    
    @cindex mouse
    @cindex gpm
    
    Ludovic Courtès's avatar
    Ludovic Courtès committed
    @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @
    
              [#:options]
    Run @var{gpm}, the general-purpose mouse daemon, with the given
    command-line @var{options}.  GPM allows users to use the mouse in the console,
    notably to select, copy, and paste text.  The default value of @var{options}
    uses the @code{ps2} protocol, which works for both USB and PS/2 mice.
    
    This service is not part of @var{%base-services}.
    @end deffn
    
    
    @anchor{guix-publish-service}
    @deffn {Scheme Procedure} guix-publish-service [#:guix @var{guix}] @
               [#:port 80] [#:host "localhost"]
    Return a service that runs @command{guix publish} listening on @var{host}
    and @var{port} (@pxref{Invoking guix publish}).
    
    This assumes that @file{/etc/guix} already contains a signing key pair as
    created by @command{guix archive --generate-key} (@pxref{Invoking guix
    archive}).  If that is not the case, the service will fail to start.
    @end deffn
    
    
    @anchor{rngd-service}
    @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
                [#:device "/dev/hwrng"]
    Return a service that runs the @command{rngd} program from @var{rng-tools}
    to add @var{device} to the kernel's entropy pool.  The service will fail if
    @var{device} does not exist.
    @end deffn
    
    @anchor{pam-limits-service}
    @cindex session limits
    @cindex ulimit
    @cindex priority
    @deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}]
    
    Return a service that installs a configuration file for the
    @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
    @code{pam_limits} module}.  The procedure optionally takes a list of
    @code{pam-limits-entry} values, which can be used to specify
    @code{ulimit} limits and nice priority limits to user sessions.
    
    The following limits definition sets two hard and soft limits for all
    login sessions of users in the @code{realtime} group:
    
    @example
    (pam-limits-service
     (list
      (pam-limits-entry "@@realtime" 'both 'rtprio 99)
      (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
    @end example
    
    The first entry increases the maximum realtime priority for
    non-privileged processes; the second entry lifts any restriction of the
    maximum address space that can be locked in memory.  These settings are
    commonly used for real-time audio systems.
    @end deffn
    
    
    @node Scheduled Job Execution
    @subsubsection Scheduled Job Execution
    
    @cindex cron
    
    @cindex mcron
    
    @cindex scheduling jobs
    The @code{(gnu services mcron)} module provides an interface to
    GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
    mcron, GNU@tie{}mcron}).  GNU@tie{}mcron is similar to the traditional
    Unix @command{cron} daemon; the main difference is that it is
    implemented in Guile Scheme, which provides a lot of flexibility when
    specifying the scheduling of jobs and their actions.
    
    
    The example below defines an operating system that runs the
    
    @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
    
    and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
    well as the @command{mkid} command on behalf of an unprivileged user
    (@pxref{mkid invocation,,, idutils, ID Database Utilities}).  It uses
    gexps to introduce job definitions that are passed to mcron
    (@pxref{G-Expressions}).
    
    
    @lisp
    (use-modules (guix) (gnu) (gnu services mcron))
    
    (use-package-modules base idutils)
    
    
    (define updatedb-job
    
      ;; Run 'updatedb' at 3AM every day.  Here we write the
      ;; job's action as a Scheme procedure.
    
      #~(job '(next-hour '(3))
    
             (lambda ()
               (execl (string-append #$findutils "/bin/updatedb")
                      "updatedb"
                      "--prunepaths=/tmp /var/tmp /gnu/store"))))
    
    
    (define garbage-collector-job
      ;; Collect garbage 5 minutes after midnight every day.
    
      ;; The job's action is a shell command.
    
      #~(job "5 0 * * *"            ;Vixie cron syntax
             "guix gc -F 1G"))
    
    
    Ludovic Courtès's avatar
    Ludovic Courtès committed
    (define idutils-job
    
      ;; Update the index database as user "charlie" at 12:15PM
      ;; and 19:15PM.  This runs from the user's home directory.
      #~(job '(next-minute-from (next-hour '(12 19)) '(15))
             (string-append #$idutils "/bin/mkid src")
             #:user "charlie"))
    
    
    (operating-system
      ;; @dots{}
      (services (cons (mcron-service (list garbage-collector-job
    
                                           updatedb-job
                                           idutils-job))
    
                      %base-services)))
    @end lisp
    
    @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
    for more information on mcron job specifications.  Below is the
    reference of the mcron service.
    
    @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}]
    Return an mcron service running @var{mcron} that schedules @var{jobs}, a
    list of gexps denoting mcron job specifications.
    
    This is a shorthand for:
    @example
    
    Ludovic Courtès's avatar
    Ludovic Courtès committed
    (service mcron-service-type
             (mcron-configuration (mcron mcron) (jobs jobs)))
    
    @end example
    @end deffn
    
    @defvr {Scheme Variable} mcron-service-type
    This is the type of the @code{mcron} service, whose value is an
    @code{mcron-configuration} object.
    
    This service type can be the target of a service extension that provides
    it additional job specifications (@pxref{Service Composition}).  In
    
    Ludovic Courtès's avatar
    Ludovic Courtès committed
    other words, it is possible to define services that provide additional
    
    mcron jobs to run.
    @end defvr
    
    @deftp {Data Type} mcron-configuration
    Data type representing the configuration of mcron.
    
    @table @asis
    @item @code{mcron} (default: @var{mcron2})
    The mcron package to use.
    
    @item @code{jobs}
    This is a list of gexps (@pxref{G-Expressions}), where each gexp
    corresponds to an mcron job specification (@pxref{Syntax, mcron job
    specifications,, mcron, GNU@tie{}mcron}).
    @end table
    @end deftp
    
    
    
    @node Log Rotation
    @subsubsection Log Rotation
    
    @cindex rottlog
    @cindex log rotation
    
    @cindex logging
    
    Log files such as those found in @file{/var/log} tend to grow endlessly,
    so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
    their contents in separate files, possibly compressed.  The @code{(gnu
    services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
    log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
    
    The example below defines an operating system that provides log rotation
    with the default settings.
    
    @lisp
    (use-modules (guix) (gnu))
    (use-service-modules admin mcron)
    (use-package-modules base idutils)
    
    (operating-system
      ;; @dots{}
      (services (cons* (mcron-service)
                       (service rottlog-service-type (rottlog-configuration)) 
                       %base-services)))
    @end lisp
    
    @defvr {Scheme Variable} rottlog-service-type
    This is the type of the Rottlog service, whose value is a
    @code{rottlog-configuration} object.
    
    This service type can define mcron jobs (@pxref{Scheduled Job
    Execution}) to run the rottlog service.
    @end defvr
    
    @deftp {Data Type} rottlog-configuration
    Data type representing the configuration of rottlog.
    
    @table @asis
    @item @code{rottlog} (default: @code{rottlog})
    The Rottlog package to use.
    
    @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
    The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
    rottlog, GNU Rot[t]log Manual}).
    
    @item @code{periodic-rotations} (default: @code{`(("weekly" %default-rotatations))})
    A list of Rottlog period-name/period-config tuples.
    
    For example, taking an example from the Rottlog manual (@pxref{Period
    Related File Examples,,, rottlog, GNU Rot[t]log Manual}), a valid tuple
    might be:
    
    @example
    ("daily" ,(plain-file "daily"
                          "\
         /var/log/apache/* @{
            storedir apache-archives
            rotate 6
            notifempty
            nocompress
         @}"))
    @end example
    
    @item @code{jobs}
    This is a list of gexps where each gexp corresponds to an mcron job
    specification (@pxref{Scheduled Job Execution}).
    @end table
    @end deftp
    
    @defvr {Scheme Variable} %default-rotations
    Specifies weekly rotation of @var{%rotated-files} and
    @code{"/var/log/shepherd.log"}.
    @end defvr
    
    @defvr {Scheme Variable} %rotated-files
    The list of syslog-controlled files to be rotated.  By default it is:
    @code{'("/var/log/messages" "/var/log/secure")}.
    @end defvr
    
    
    @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 {Scheme 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 {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
    
           [#:gateway #f] [#:name-servers @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
    
    @cindex wireless
    @cindex WiFi
    
    @cindex network management
    
    @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
    
    Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
    management daemon that aims to simplify wired and wireless networking.
    
    This service adds the @var{wicd} package to the global profile, providing
    several commands to interact with the daemon and configure networking:
    @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
    and @command{wicd-curses} user interfaces.
    
    @end deffn
    
    
    @cindex NetworkManager
    @deffn {Scheme Procedure} network-manager-service @
           [#:network-manager @var{network-manager}]
    Return a service that runs NetworkManager, a network connection manager
    
    attempting to keep network connectivity active when available.
    
    @cindex Connman
    @deffn {Scheme Procedure} connman-service @
           [#:connman @var{connman}]
    Return a service that runs @url{https://01.org/connman,Connman}, a network
    connection manager.
    
    This service adds the @var{connman} package to the global profile, providing
    several the @command{connmanctl} command to interact with the daemon and
    configure networking."
    @end deffn
    
    
    @cindex WPA Supplicant
    @deffn {Scheme Procedure} wpa-supplicant-service @
           [#:wpa-supplicant @var{wpa-supplicant}]
    Return a service that runs @url{https://w1.fi/wpa_supplicant/,WPA
    supplicant}, an authentication daemon required to authenticate against
    encrypted WiFi or ethernet networks. Service is started to listen for
    requests on D-Bus.
    @end deffn
    
    
    @cindex NTP
    @cindex real time clock
    
    @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @
    
      [#:servers @var{%ntp-servers}] @
      [#:allow-large-adjustment? #f]
    
    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}.
    
    @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to
    make an initial adjustment of more than 1,000 seconds.
    
    @end deffn
    
    @defvr {Scheme Variable} %ntp-servers
    List of host names used as the default NTP servers.
    @end defvr
    
    
    @cindex Tor
    
    @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}]
    Return a service to run the @uref{https://torproject.org, Tor} anonymous
    networking daemon.
    
    The daemon runs as the @code{tor} unprivileged user.  It is passed
    
    @var{config-file}, a file-like object, with an additional @code{User tor} line
    and lines for hidden services added via @code{tor-hidden-service}.  Run
    @command{man tor} for information about the configuration file.
    @end deffn
    
    
    @cindex hidden service
    
    @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
    Define a new Tor @dfn{hidden service} called @var{name} and implementing
    @var{mapping}.  @var{mapping} is a list of port/host tuples, such as:
    
    @example
    
     '((22 "127.0.0.1:22")
       (80 "127.0.0.1:8080"))
    
    @end example
    
    In this example, port 22 of the hidden service is mapped to local port 22, and
    port 80 is mapped to local port 8080.
    
    
    This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
    the @file{hostname} file contains the @code{.onion} host name for the hidden
    
    service.
    
    See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
    project's documentation} for more information.
    
    @deffn {Scheme 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 services.
    
    @cindex SSH
    @cindex SSH server
    
    @deffn {Scheme 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
    
    @cindex SSH
    @cindex SSH server
    
    @deffn {Scheme Variable} openssh-service-type
    This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
    shell daemon, @command{sshd}.  Its value must be an
    @code{openssh-configuration} record as in this example:
    
    @example
    (service openssh-service-type
             (openssh-configuration
               (x11-forwarding? #t)
               (permit-root-login 'without-password)))
    @end example
    
    See below for details about @code{openssh-configuration}.
    
    @deftp {Data Type} openssh-configuration
    This is the configuration record for OpenSSH's @command{sshd}.
    
    @table @asis
    @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
    Name of the file where @command{sshd} writes its PID.
    
    @item @code{port-number} (default: @code{22})
    TCP port on which @command{sshd} listens for incoming connections.
    
    @item @code{permit-root-login} (default: @code{#f})
    This field determines whether and when to allow logins as root.  If
    @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
    If it's the symbol @code{'without-password}, then root logins are
    permitted but not with password-based authentication.
    
    @item @code{allow-empty-passwords?} (default: @code{#f})
    When true, users with empty passwords may log in.  When false, they may
    not.
    
    @item @code{password-authentication?} (default: @code{#t})
    When true, users may log in with their password.  When false, they have
    other authentication methods.
    
    @item @code{public-key-authentication?} (default: @code{#t})
    When true, users may log in using public key authentication.  When
    false, users have to use other authentication method.
    
    Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
    This is used only by protocol version 2.
    
    @item @code{rsa-authentication?} (default: @code{#t})
    When true, users may log in using pure RSA authentication.  When false,
    users have to use other means of authentication.  This is used only by
    protocol 1.
    
    @item @code{x11-forwarding?} (default: @code{#f})
    When true, forwarding of X11 graphical client connections is
    enabled---in other words, @command{ssh} options @option{-X} and
    @option{-Y} will work.
    
    @item @code{protocol-number} (default: @code{2})
    The SSH protocol number to use.
    @end table
    @end deftp
    
    
    @deffn {Scheme Procedure} dropbear-service [@var{config}]
    Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
    daemon} with the given @var{config}, a @code{<dropbear-configuration>}
    object.
    
    For example, to specify a Dropbear service listening on port 1234, add
    this call to the operating system's @code{services} field:
    
    @example
    (dropbear-service (dropbear-configuration
                        (port-number 1234)))
    @end example
    @end deffn
    
    @deftp {Data Type} dropbear-configuration
    This data type represents the configuration of a Dropbear SSH daemon.
    
    @table @asis
    @item @code{dropbear} (default: @var{dropbear})
    The Dropbear package to use.
    
    @item @code{port-number} (default: 22)
    The TCP port where the daemon waits for incoming connections.
    
    @item @code{syslog-output?} (default: @code{#t})
    Whether to enable syslog output.
    
    @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
    File name of the daemon's PID file.
    
    @item @code{root-login?} (default: @code{#f})
    Whether to allow @code{root} logins.
    
    @item @code{allow-empty-passwords?} (default: @code{#f})
    Whether to allow empty passwords.
    
    @item @code{password-authentication?} (default: @code{#t})
    Whether to enable password-based authentication.
    @end table
    @end deftp
    
    
    @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 {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @
    
              [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
              [#:ipv6? #t] [#:wide-area? #f] @
    
              [#:domains-to-browse '()] [#:debug? #f]
    
    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/}), and
    extends the name service cache daemon (nscd) so that it can resolve
    @code{.local} host names using
    
    @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}.  Additionally,
    add the @var{avahi} package to the system profile so that commands such as
    @command{avahi-browse} are directly usable.
    
    
    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
    
    @cindex X11
    @cindex X Window System
    
    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.
    
    @deftp {Data Type} sddm-configuration
    This is the data type representing the sddm service configuration.
    
    @table @asis
    @item @code{display-server} (default: "x11")
    Select display server to use for the greeter. Valid values are "x11"
    or "wayland".
    
    @item @code{numlock} (default: "on")
    Valid values are "on", "off" or "none".
    
    @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
    Command to run when halting.
    
    @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
    Command to run when rebooting.
    
    @item @code{theme} (default "maldives")
    Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
    
    @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
    Directory to look for themes.
    
    @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
    Directory to look for faces.
    
    @item @code{default-path} (default "/run/current-system/profile/bin")
    Default PATH to use.
    
    @item @code{minimum-uid} (default 1000)
    Minimum UID to display in SDDM.
    
    @item @code{maximum-uid} (default 2000)
    Maximum UID to display in SDDM
    
    @item @code{remember-last-user?} (default #t)
    Remember last user.
    
    @item @code{remember-last-session?} (default #t)
    Remember last session.
    
    @item @code{hide-users} (default "")
    Usernames to hide from SDDM greeter.
    
    @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
    Users with shells listed will be hidden from the SDDM greeter.
    
    @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
    Script to run before starting a wayland session.
    
    @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
    Directory to look for desktop files starting wayland sessions.
    
    @item @code{xorg-server-path} (default @code{xorg-start-command})
    Path to xorg-server.
    
    @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
    Path to xauth.
    
    @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
    Path to Xephyr.
    
    @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
    Script to run after starting xorg-server.
    
    @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
    Script to run before stopping xorg-server.
    
    @item @code{xsession-command} (default: @code{xinitr })
    Script to run before starting a X session.
    
    @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
    Directory to look for desktop files starting X sessions.
    
    @item @code{minimum-vt} (default: 7)
    Minimum VT to use.
    
    @item @code{xserver-arguments} (default "-nolisten tcp")
    Arguments to pass to xorg-server.
    
    @item @code{auto-login-user} (default "")
    User to use for auto-login.
    
    @item @code{auto-login-session} (default "")
    Desktop file to use for auto-login.
    
    @item @code{relogin?} (default #f)
    Relogin after logout.
    
    @end table
    @end deftp
    
    
    @cindex login manager
    
    @deffn {Scheme Procedure} sddm-service config
    Return a service that spawns the SDDM graphical login manager for config of
    type @code{<sddm-configuration>}.
    
    @example
      (sddm-service (sddm-configuration
                     (auto-login-user "Alice")
                     (auto-login-session "xfce.desktop")))
    @end example
    @end deffn
    
    
    @deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @
    
      [#:auto-login? #f] [#:default-user ""] [#:startx] @
      [#:theme @var{%default-slim-theme}] @
    
      [#:theme-name @var{%default-slim-theme-name}]
    
    Return a service that spawns the SLiM graphical login manager, which in
    turn starts the X display server with @var{startx}, a command as returned by
    @code{xorg-start-command}.
    
    @cindex X session
    
    SLiM automatically looks for session types described by the @file{.desktop}
    files in @file{/run/current-system/profile/share/xsessions} and allows users
    to choose a session from the log-in screen using @kbd{F1}.  Packages such as
    @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
    adding them to the system-wide set of packages automatically makes them
    available at the log-in screen.
    
    In addition, @file{~/.xsession} files are honored.  When available,
    @file{~/.xsession} must be an executable that starts a window manager
    and/or other X clients.
    
    
    When @var{allow-empty-passwords?} is true, allow logins with an empty
    password.  When @var{auto-login?} is true, log in automatically as
    @var{default-user}.
    
    If @var{theme} is @code{#f}, use the default log-in theme; otherwise
    
    @var{theme} must be a gexp denoting the name of a directory containing the
    theme to use.  In that case, @var{theme-name} specifies the name of the
    theme.
    
    @defvr {Scheme Variable} %default-theme
    @defvrx {Scheme Variable} %default-theme-name
    The G-Expression denoting the default SLiM theme and its name.
    @end defvr
    
    
    @deffn {Scheme Procedure} xorg-start-command [#:guile] @
    
      [#:configuration-file #f] [#:xorg-server @var{xorg-server}]
    
    Return a derivation that builds a @var{guile} script to start the X server
    
    from @var{xorg-server}.  @var{configuration-file} is the server configuration
    file or a derivation that builds it; when omitted, the result of
    @code{xorg-configuration-file} is used.
    
    Usually the X server is started by a login manager.
    @end deffn
    
    
    @deffn {Scheme Procedure} xorg-configuration-file @
    
      [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
    
    Return a configuration file for the Xorg server containing search paths for
    all the common drivers.
    
    
    @var{drivers} must be either the empty list, in which case Xorg chooses a
    graphics driver automatically, or a list of driver names that will be tried in
    
    this order---e.g., @code{(\"modesetting\" \"vesa\")}.
    
    
    Likewise, when @var{resolutions} is the empty list, Xorg chooses an
    appropriate screen resolution; otherwise, it must be a list of
    resolutions---e.g., @code{((1024 768) (640 480))}.
    
    
    Last, @var{extra-config} is a list of strings or objects appended to the
    @code{text-file*} argument list.  It is used to pass extra text to be added
    verbatim to the configuration file.
    
    @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}]
    Add @var{package}, a package for a screen-locker or screen-saver whose
    command is @var{program}, to the set of setuid programs and add a PAM entry
    for it.  For example:
    
    @lisp
    (screen-locker-service xlockmore "xlock")
    @end lisp
    
    makes the good ol' XlockMore usable.
    @end deffn
    
    
    
    Andy Wingo's avatar
    Andy Wingo committed
    @node Printing Services
    @subsubsection Printing Services
    
    The @code{(gnu services cups)} module provides a Guix service definition
    for the CUPS printing service.  To add printer support to a GuixSD
    system, add a @code{cups-service} to the operating system definition:
    
    @deffn {Scheme Variable} cups-service-type
    The service type for the CUPS print server.  Its value should be a valid
    CUPS configuration (see below).  For example:
    @example
    (service cups-service-type (cups-configuration))
    @end example
    @end deffn
    
    The CUPS configuration controls the basic things about your CUPS
    installation: what interfaces it listens on, what to do if a print job
    fails, how much logging to do, and so on.  To actually add a printer,
    you have to visit the @url{http://localhost:631} URL, or use a tool such
    as GNOME's printer configuration services.  By default, configuring a
    CUPS service will generate a self-signed certificate if needed, for
    secure connections to the print server.
    
    One way you might want to customize CUPS is to enable or disable the web
    interface.  You can do that directly, like this:
    
    @example
    (service cups-service-type
             (cups-configuration
               (web-interface? #f)))
    @end example
    
    The available configuration parameters follow.  Each parameter
    definition is preceded by its type; for example, @samp{string-list foo}
    indicates that the @code{foo} parameter should be specified as a list of
    strings.  There is also a way to specify the configuration as a string,
    if you have an old @code{cupsd.conf} file that you want to port over
    from some other system; see the end for more details.
    
    @c The following documentation was initially generated by
    @c (generate-documentation) in (gnu services cups).  Manually maintained
    @c documentation is better, so we shouldn't hesitate to edit below as
    @c needed.  However if the change you want to make to this documentation
    @c can be done in an automated way, it's probably easier to change
    @c (generate-documentation) than to make it below and have to deal with
    @c the churn as CUPS updates.
    
    
    Available @code{cups-configuration} fields are:
    
    @deftypevr {@code{cups-configuration} parameter} package cups
    The CUPS package.
    @end deftypevr
    
    @deftypevr {@code{cups-configuration} parameter} package-list extensions
    Drivers and other extensions to the CUPS package.
    @end deftypevr
    
    @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
    Configuration of where to write logs, what directories to use for print
    spools, and related privileged configuration parameters.
    
    Available @code{files-configuration} fields are:
    
    @deftypevr {@code{files-configuration} parameter} log-location access-log
    Defines the access log filename.  Specifying a blank filename disables
    access log generation.  The value @code{stderr} causes log entries to be
    sent to the standard error file when the scheduler is running in the
    foreground, or to the system log daemon when run in the background.  The
    value @code{syslog} causes log entries to be sent to the system log
    daemon.  The server name may be included in filenames using the string
    @code{%s}, as in @code{/var/log/cups/%s-access_log}.
    
    Defaults to @samp{"/var/log/cups/access_log"}.
    @end deftypevr
    
    @deftypevr {@code{files-configuration} parameter} file-name cache-dir
    Where CUPS should cache data.
    
    Defaults to @samp{"/var/cache/cups"}.
    @end deftypevr
    
    @deftypevr {@code{files-configuration} parameter} string config-file-perm
    Specifies the permissions for all configuration files that the scheduler
    writes.
    
    Note that the permissions for the printers.conf file are currently
    masked to only allow access from the scheduler user (typically root).
    This is done because printer device URIs sometimes contain sensitive
    authentication information that should not be generally known on the
    system.  There is no way to disable this security feature.
    
    Defaults to @samp{"0640"}.
    @end deftypevr
    
    @deftypevr {@code{files-configuration} parameter} log-location error-log
    Defines the error log filename.  Specifying a blank filename disables
    access log generation.  The value @code{stderr} causes log entries to be
    sent to the standard error file when the scheduler is running in the
    foreground, or to the system log daemon when run in the background.  The
    value @code{syslog} causes log entries to be sent to the system log
    daemon.  The server name may be included in filenames using the string
    @code{%s}, as in @code{/var/log/cups/%s-error_log}.
    
    Defaults to @samp{"/var/log/cups/error_log"}.
    @end deftypevr
    
    @deftypevr {@code{files-configuration} parameter} string fatal-errors
    Specifies which errors are fatal, causing the scheduler to exit.  The
    kind strings are:
    
    @table @code
    @item none
    No errors are fatal.
    
    @item all
    All of the errors below are fatal.
    
    @item browse
    Browsing initialization errors are fatal, for example failed connections
    to the DNS-SD daemon.
    
    @item config
    Configuration file syntax errors are fatal.
    
    @item listen
    Listen or Port errors are fatal, except for IPv6 failures on the
    loopback or @code{any} addresses.
    
    @item log
    Log file creation or write errors are fatal.