aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBruno Victal <mirai@makinata.eu>2023-01-27 21:06:11 +0000
committerLudovic Courtès <ludo@gnu.org>2023-02-09 01:07:39 +0100
commit22dd558c70901a336de97187f0470be584571158 (patch)
tree9fede9cd565a0453324ade4975524af3c205125f /doc
parent7ad98c571e1bd19b36b1cde7a49868b589fdb3ca (diff)
downloadguix-22dd558c70901a336de97187f0470be584571158.tar
guix-22dd558c70901a336de97187f0470be584571158.tar.gz
services: Add hosts-service-type.
* gnu/services/base.scm (<host>): New record type. (host): New procedure. (hosts-service-type): New variable. * doc/guix.texi (Service Reference): Document it. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'doc')
-rw-r--r--doc/guix.texi73
1 files changed, 72 insertions, 1 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 359c9b7a47..9a6a653d86 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -113,7 +113,7 @@ Copyright @copyright{} 2022 Bruno Victal@*
Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
Copyright @copyright{} 2023 Giacomo Leidi@*
Copyright @copyright{} 2022 Antero Mejr@*
-Copyright @copyright{} 2022 Bruno Victal@*
+Copyright @copyright{} 2023 Bruno Victal@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -40473,6 +40473,77 @@ In this example, the effect would be to add an @file{/etc/issue} file
pointing to the given file.
@end defvar
+@defvar hosts-service-type
+Type of the service that populates the entries for (@file{/etc/hosts}).
+This service type can be extended by passing it a list of
+@code{host} records.
+
+@c TRANSLATORS: The domain names below SHOULD NOT be translated.
+@c They're domains reserved for use in documentation. (RFC6761 Section 6.5)
+@c The addresses used are explained in RFC3849 and RFC5737.
+@lisp
+(simple-service 'add-extra-hosts
+ hosts-service-type
+ (list (host "192.0.2.1" "example.com"
+ '("example.net" "example.org"))
+ (host "2001:db8::1" "example.com"
+ '("example.net" "example.org"))))
+@end lisp
+
+@quotation Note
+@cindex @file{/etc/host} default entries
+By default @file{/etc/host} comes with the following entries:
+@example
+127.0.0.1 localhost @var{host-name}
+::1 localhost @var{host-name}
+@end example
+
+For most setups this is what you want though if you find yourself in
+the situation where you want to change the default entries, you can
+do so in @code{operating-system}.@pxref{operating-system Reference,@code{essential-services}}
+
+The following example shows how one would unset @var{host-name}
+from being an alias of @code{localhost}.
+@lisp
+(operating-system
+ ;; @dots{}
+
+ (essential-services
+ (modify-services
+ (operation-system-default-essential-services this-operating-system)
+ (hosts-service-type config => (list
+ (host "127.0.0.1" "localhost")
+ (host "::1" "localhost"))))))
+@end lisp
+@end quotation
+
+@deftp {Data Type} host
+Available @code{host} fields are:
+
+@table @asis
+@item @code{address} (type: string)
+IP address.
+
+@item @code{canonical-name} (type: string)
+Hostname.
+
+@item @code{aliases} (default: @code{'()}) (type: list-of-string)
+Additional aliases that map to the same @code{canonical-name}.
+
+@end table
+@end deftp
+
+@defun host address canonical-name [aliases]
+Procedure for creating @code{host} records.
+@end defun
+
+@quotation Note
+The @code{host} data type constructor is @code{%host} though it is
+tiresome to create multiple records with it so in practice the procedure
+@code{host} (which wraps around @code{%host}) is used instead.
+@end quotation
+@end defvar
+
@defvar setuid-program-service-type
Type for the ``setuid-program service''. This service collects lists of
executable file names, passed as gexps, and adds them to the set of