(gnu system nss) module provides bindings to the
configuration file of the libc name service switch or NSS
(see NSS Configuration File in The GNU C Library Reference
Manual). In a nutshell, the NSS is a mechanism that allows libc to be
extended with new “name” lookup methods for system databases, which
includes host names, service names, user accounts, and more (see System Databases and Name Service Switch in The GNU
C Library Reference Manual).
The NSS configuration specifies, for each system database, which lookup
method is to be used, and how the various methods are chained
together—for instance, under which circumstances NSS should try the
next method in the list. The NSS configuration is given in the
name-service-switch field of
As an example, the declaration below configures the NSS to use the
back-end, which supports host name lookups over multicast DNS (mDNS)
for host names ending in
(name-service-switch (hosts (list %files ;first, check /etc/hosts ;; If the above did not succeed, try ;; with 'mdns_minimal'. (name-service (name "mdns_minimal") ;; 'mdns_minimal' is authoritative for ;; '.local'. When it returns "not found", ;; no need to try the next methods. (reaction (lookup-specification (not-found => return)))) ;; Then fall back to DNS. (name-service (name "dns")) ;; Finally, try with the "full" 'mdns'. (name-service (name "mdns")))))
Do not worry: the
%mdns-host-lookup-nss variable (see below)
contains this configuration, so you will not have to type it if all you
want is to have
.local host lookup working.
Note that, in this case, in addition to setting the
name-service-switch of the
you also need to use
%desktop-services, which includes it
(see Desktop Services). Doing this makes
to the name service cache daemon (see
For convenience, the following variables provide typical NSS configurations.
This is the default name service switch configuration, a
This is the name service switch configuration with support for host name
lookup over multicast DNS (mDNS) for host names ending in
The reference for name service switch configuration is given below. It
is a direct mapping of the configuration file format of the C library , so
please refer to the C library manual for more information (see NSS
Configuration File in The GNU C Library Reference Manual).
Compared to the configuration file format of libc NSS, it has the advantage
not only of adding this warm parenthetic feel that we like, but also
static checks: you will know about syntax errors and typos as soon as you
This is the data type representation the configuration of libc’s name service switch (NSS). Each field below represents one of the supported system databases.
The system databases handled by the NSS. Each of these fields must be a
<name-service> objects (see below).
This is the data type representing an actual name service and the associated lookup action.
A string denoting the name service (see Services in the NSS configuration in The GNU C Library Reference Manual).
Note that name services listed here must be visible to nscd. This is
achieved by passing the
#:name-services argument to
nscd-service the list of packages providing the needed name
An action specified using the
(see Actions in the NSS configuration in The GNU C Library
Reference Manual). For example: