unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Bruno Victal <mirai@makinata.eu>
Cc: 60735-done@debbugs.gnu.org
Subject: bug#60735: [PATCH 0/2] Implement etc-hosts-service-type
Date: Thu, 09 Feb 2023 00:57:39 +0100	[thread overview]
Message-ID: <87zg9nvhfw.fsf_-_@gnu.org> (raw)
In-Reply-To: <55ce2a77151a50d5e6e179ce53b437a3d0dc6d2b.1674853530.git.mirai@makinata.eu> (Bruno Victal's message of "Fri, 27 Jan 2023 21:06:13 +0000")

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

Hi Bruno,

I’ve finally applied this v3 with the changes below:

  • spelling “host name” as two words and tweaking docstrings of public
    procedures;

  • keeping ‘local-host-aliases’ unchanged (returning a string) as this
    is public and documented, and adding ‘local-host-entries’ to return
    a list of <host> records;

  • referencing to ‘%operating-system-hosts-file’ (with leading percent
    sign) internally to avoid deprecation warnings.

Thank you!

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 5110 bytes --]

diff --git a/doc/guix.texi b/doc/guix.texi
index 5edc0d20cc..2b21e12b88 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40246,10 +40246,7 @@ from being an alias of @code{localhost}.
      (operation-system-default-essential-services this-operating-system)
      (hosts-service-type config => (list
                                      (host "127.0.0.1" "localhost")
-                                     (host "::1"       "localhost")))))
-
-   ;; @dots{}
-)
+                                     (host "::1"       "localhost"))))))
 @end lisp
 @end quotation
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 53eda9ea1e..e9fdafd5d0 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -700,16 +700,16 @@ (define* (rngd-service #:key
 ;;;
 
 (define (valid-name? name)
-  "Return true if @var{name} is likely to be a valid hostname."
+  "Return true if @var{name} is likely to be a valid host name."
   (false-if-exception (not (string-any char-set:whitespace name))))
 
 (define-compile-time-procedure (assert-valid-name (name valid-name?))
-  "Ensure @var{name} is likely to be a valid hostname."
+  "Ensure @var{name} is likely to be a valid host name."
   ;; TODO: RFC compliant implementation.
   (unless (valid-name? name)
     (raise
      (make-compound-condition
-      (formatted-message (G_ "hostname '~a' contains invalid characters")
+      (formatted-message (G_ "host name '~a' contains invalid characters")
                          name)
       (condition (&error-location
                   (location
@@ -728,7 +728,12 @@ (define-record-type* <host> %host
                   (sanitize (cut map assert-valid-name <>))))
 
 (define* (host address canonical-name #:optional (aliases '()))
-  "Public constructor for <host> records."
+  "Return a new record for the host at @var{address} with the given
+@var{canonical-name} and possibly @var{aliases}.
+
+@var{address} must be a string denoting a valid IPv4 or IPv6 address, and
+@var{canonical-name} and the strings listed in @var{aliases} must be valid
+host names."
   (%host
    (address address)
    (canonical-name canonical-name)
diff --git a/gnu/system.scm b/gnu/system.scm
index e8904cfab7..df60fda53b 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -170,7 +170,8 @@ (define-module (gnu system)
             read-boot-parameters-file
             boot-parameters->menu-entry
 
-            local-host-aliases
+            local-host-aliases                    ;deprecated
+            local-host-entries
             %root-account
             %setuid-programs
             %sudoers-specification
@@ -749,7 +750,7 @@ (define known-fs
          (swaps        (swap-services os))
          (procs        (service user-processes-service-type))
          (host-name    (operating-system-host-name os))
-         (hosts-file   (operating-system-hosts-file os))
+         (hosts-file   (%operating-system-hosts-file os))
          (entries      (operating-system-directory-base-entries os)))
     (cons* (service system-service-type entries)
            (service linux-builder-service-type
@@ -776,7 +777,7 @@ (define known-fs
                (simple-service 'deprecated-hosts-file etc-service-type
                                (list `("hosts" ,hosts-file)))
                (service hosts-service-type
-                        (local-host-aliases host-name)))
+                        (local-host-entries host-name)))
            (service fstab-service-type
                     (filter file-system-needed-for-boot?
                             (operating-system-file-systems os)))
@@ -798,7 +799,7 @@ (define known-fs
 
 (define (hurd-default-essential-services os)
   (let ((host-name    (operating-system-host-name os))
-        (hosts-file   (operating-system-hosts-file os))
+        (hosts-file   (%operating-system-hosts-file os))
         (entries      (operating-system-directory-base-entries os)))
     (list (service system-service-type entries)
           %boot-service
@@ -824,7 +825,7 @@ (define (hurd-default-essential-services os)
               (simple-service 'deprecated-hosts-file etc-service-type
                               (list `("hosts" ,hosts-file)))
               (service hosts-service-type
-                       (local-host-aliases host-name)))
+                       (local-host-entries host-name)))
           (service setuid-program-service-type
                    (operating-system-setuid-programs os))
           (service profile-service-type (operating-system-packages os)))))
@@ -943,8 +944,14 @@ (define %default-issue
   "
 This is the GNU system.  Welcome.\n")
 
-(define (local-host-aliases host-name)
+(define-deprecated (local-host-aliases host-name)
+  local-host-entries
   "Return aliases for HOST-NAME, to be used in /etc/hosts."
+  (string-append "127.0.0.1 localhost " host-name "\n"
+                 "::1       localhost " host-name "\n"))
+
+(define (local-host-entries host-name)
+  "Return <host> records for @var{host-name}."
   (map (lambda (address)
          (host address "localhost" (list host-name)))
        '("127.0.0.1" "::1")))

      reply	other threads:[~2023-02-08 23:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 17:26 [bug#60735] [PATCH 0/2] Implement etc-hosts-service-type Bruno Victal
2023-01-11 17:28 ` [bug#60735] [PATCH 1/2] services: Add etc-hosts-service-type Bruno Victal
2023-01-14 17:30   ` [bug#60735] [PATCH 0/2] Implement etc-hosts-service-type Ludovic Courtès
2023-01-11 17:28 ` [bug#60735] [PATCH 2/2] services: Add block-facebook-hosts-service-type Bruno Victal
2023-01-18 16:54 ` [bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type Bruno Victal
2023-01-18 16:54   ` [bug#60735] [PATCH v2 2/3] system: Deprecate hosts-file Bruno Victal
2023-01-23 22:37     ` Ludovic Courtès
2023-01-23 23:19       ` Bruno Victal
2023-01-24  8:53         ` Ludovic Courtès
2023-01-18 16:54   ` [bug#60735] [PATCH v2 3/3] services: Add block-facebook-hosts-service-type Bruno Victal
2023-01-23 22:40     ` Ludovic Courtès
2023-01-25 20:34       ` Bruno Victal
2023-01-23 22:30   ` [bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type Ludovic Courtès
2023-01-23 22:47   ` Ludovic Courtès
2023-01-25 20:29     ` Bruno Victal
2023-01-27 21:06 ` [bug#60735] [PATCH v3 1/3] services: Add hosts-service-type Bruno Victal
2023-01-27 21:06   ` [bug#60735] [PATCH v3 2/3] system: Deprecate hosts-file Bruno Victal
2023-01-27 21:06   ` [bug#60735] [PATCH v3 3/3] services: Add block-facebook-hosts-service-type Bruno Victal
2023-02-08 23:57     ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zg9nvhfw.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=60735-done@debbugs.gnu.org \
    --cc=mirai@makinata.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).