summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorBruno Victal <mirai@makinata.eu>2023-01-27 21:06:12 +0000
committerLudovic Courtès <ludo@gnu.org>2023-02-09 01:07:47 +0100
commit802ea1f3a43e5fb8d0b8bd2882954d8a6e49cde6 (patch)
tree3adf9c824a6531b7ad74fc21bcba080772be7bc2 /doc
parent22dd558c70901a336de97187f0470be584571158 (diff)
downloadguix-802ea1f3a43e5fb8d0b8bd2882954d8a6e49cde6.tar.gz
system: Deprecate hosts-file.
* gnu/system.scm (operating-system-hosts-file): Deprecate procedure.
(warn-hosts-file-field-deprecation): New procedure, helper for
deprecated variable.
(operating-system)[hosts-file]: Use helper to warn deprecated field.
(local-host-aliases): Mark as deprecated.
(local-host-entries): New procedure.
(operating-system-default-essential-services,
hurd-default-essential-services): Use hosts-service-type.  Use
'%operating-system-hosts-file' and 'local-host-entries'.
(default-/etc/hosts): Remove procedure.
(operating-system-etc-service): Remove hosts file.
* doc/guix.texi (operating-system Reference)
(Networking Services) (Virtualization Services): Rewrite documentation
entries to use hosts-service-type.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'doc')
-rw-r--r--doc/guix.texi60
1 files changed, 32 insertions, 28 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 9a6a653d86..d1cb6eebf7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -16481,13 +16481,6 @@ 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}.
 
@@ -21012,22 +21005,33 @@ 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}}):
+This variable is typically used as a @code{hosts-service-type}
+service extension (@pxref{Service Reference, @code{hosts-service-type}}):
 
 @lisp
-(use-modules (gnu) (guix))
+(use-modules (gnu) (gnu services) (guix) (srfi srfi-1) (ice-9 match))
+(use-service-modules networking)
 
 (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))))
+  ;; @dots{}
+
+  (service
+    (simple-service 'block-facebook-hosts hosts-service-type
+                    (let ((host-pairs
+                            (filter-map
+                              (lambda (x)
+                                (and (not (or (string-null? x)
+                                              (string-prefix? "#" x)))
+	                             (remove string-null?
+                                             (string-split
+                                               x
+                                               char-set:whitespace))))
+                              (string-split %facebook-host-aliases #\newline))))
+                      (map (match-lambda
+                             ((addr name)
+                              (host addr name)))
+                           host-pairs)))
+    ;; @dots{}
 @end lisp
 
 This mechanism can prevent programs running locally, such as Web
@@ -34555,7 +34559,7 @@ and to make maintenance and recovery tasks easy.  It consists of multiple
 services which are described later in this section.  In addition to the Ganeti
 service, you will need the OpenSSH service (@pxref{Networking Services,
 @code{openssh-service-type}}), and update the @file{/etc/hosts} file
-(@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
+(@pxref{Service Reference, @code{hosts-service-type}}) with the cluster name
 and address (or use a DNS server).
 
 All nodes participating in a Ganeti cluster should have the same Ganeti and
@@ -34569,14 +34573,6 @@ cluster node that supports multiple storage backends, and installs the
 (operating-system
   ;; @dots{}
   (host-name "node1")
-  (hosts-file (plain-file "hosts" (format #f "
-127.0.0.1       localhost
-::1             localhost
-
-192.168.1.200   ganeti.example.com
-192.168.1.201   node1.example.com node1
-192.168.1.202   node2.example.com node2
-")))
 
   ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
   ;; in order to use the "plain", "drbd" and "rbd" storage backends.
@@ -34604,6 +34600,14 @@ cluster node that supports multiple storage backends, and installs the
                           (openssh-configuration
                            (permit-root-login 'prohibit-password)))
 
+                 (simple-service 'ganeti-hosts-entries hosts-service-type
+                                 (list
+                                   (host "192.168.1.200" "ganeti.example.com")
+                                   (host "192.168.1.201" "node1.example.com"
+                                         '("node1"))
+                                   (host "192.168.1.202" "node2.example.com"
+                                         '("node2"))))
+
                  (service ganeti-service-type
                           (ganeti-configuration
                            ;; This list specifies allowed file system paths