all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Bruno Victal <mirai@makinata.eu>
Cc: 60735@debbugs.gnu.org
Subject: [bug#60735] [PATCH 0/2] Implement etc-hosts-service-type
Date: Sat, 14 Jan 2023 18:30:08 +0100	[thread overview]
Message-ID: <87v8l981nj.fsf_-_@gnu.org> (raw)
In-Reply-To: <0248101fa24f80f52a0412930598a7bbc9f71194.1673457786.git.mirai@makinata.eu> (Bruno Victal's message of "Wed, 11 Jan 2023 17:28:13 +0000")

Hello Bruno,

Bruno Victal <mirai@makinata.eu> skribis:

> * gnu/services.scm (etc-hosts-service-type): New variable.
> * 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.
> (operating-system-default-essential-services)
> (hurd-default-essential-services): Use etc-hosts-service-type.
> (local-host-aliases): Return a list of strings representing hosts file entries.
> (default-/etc/hosts): Remove procedure.
> (operating-system-etc-service): Remove hosts file.
> * doc/guix.texi: Document it.

Neat!  Some comments:

> +@defvar etc-hosts-service-type
> +Type of the service that populates the entries for (@file{/etc/hosts}).
> +This service can be extended by passing it lists of strings such as:
> +
> +@c TRANSLATORS: The domain names below SHOULD NOT be translated.
> +@c They're domains reserved for use in documentation. (RFC6761 Section 6.5)
> +@lisp
> +(list "127.0.0.1    example.com example.net"
> +      "::1          example.com example.net"
> +@end lisp
> +@end defvar

[...]

> +(define etc-hosts-service-type
> +  ;; Extend etc-service-type with a entry for @file{/etc/hosts}.
> +  (service-type
> +   (name 'etc-hosts)
> +   (extensions
> +    (list
> +     (service-extension etc-service-type
> +                        (lambda (lst)
> +                          `(("hosts"
> +                             ,(plain-file "hosts"
> +                                          (string-join lst "\n"
> +                                                       'suffix))))))))
> +   (compose concatenate)
> +   (extend append)
> +   (description "Populate the @file{/etc/hosts} file.")))

Two suggestions:

  1. Calling it ‘hosts-service-type’.

  2. Instead of plain strings, take records along the lines of:

       (define-record-type* <host> host make-host
         host?
         (address         host-address)  ;string
         (canonical-name  host-canonical-name)  ;string
         (aliases         host-aliases (default '()))) ;list of strings

WDYT?

If “host” is too likely to clash, we can call it <host-name-binding> or
something, but I think it should be fine.

> +(define-with-syntax-properties (warn-hosts-file-field-deprecation
> +                                (value properties))
> +  (when value
> +    (warning (source-properties->location properties)
> +             (G_ "the 'hosts-file' field is deprecated, please use \
> +'etc-hosts-service-type' instead~%")))
> +  value)

Could you move deprecation to a separate patch?

Apart from that it LGTM, thank you!

Ludo’.




  reply	other threads:[~2023-01-14 17:31 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   ` Ludovic Courtès [this message]
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     ` bug#60735: [PATCH 0/2] Implement etc-hosts-service-type Ludovic Courtès

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

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

  git send-email \
    --in-reply-to=87v8l981nj.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=60735@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.