From: "Ludovic Courtès" <ludo@gnu.org>
To: Bruno Victal <mirai@makinata.eu>
Cc: 60735@debbugs.gnu.org
Subject: [bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type.
Date: Mon, 23 Jan 2023 23:47:35 +0100 [thread overview]
Message-ID: <87edrkyik8.fsf@gnu.org> (raw)
In-Reply-To: <e283599f4b6235ca2124c3d73a09e8e2338a5b3e.1674060850.git.mirai@makinata.eu> (Bruno Victal's message of "Wed, 18 Jan 2023 16:54:11 +0000")
Bruno Victal <mirai@makinata.eu> skribis:
> * gnu/services.scm (etc-hosts-service-type): New variable.
> * doc/guix.texi: Document it.
Other things that crossed my mind; sorry for not noticing earlier!
> +++ b/gnu/services.scm
Should this be in (gnu services base) instead?
> + (make-compound-condition
> + (formatted-message (G_ "hostname '~a' contains invalid characters.")
No period please.
> +(define-record-type* <host-entry> host-entry
> + make-host-entry host-entry?
> + (address host-entry-address)
> + (canonical-name host-entry-canonical-name
> + (sanitize assert-valid-name))
> + (aliases host-entry-aliases
> + (default '())
> + (sanitize (cut map assert-valid-name <>))))
> +
> +(define* (host address canonical-name #:optional (aliases '()))
> + "More compact way of creating <host> records"
> + (make-host-entry address canonical-name aliases))
I just realized that ‘make-host-entry’ won’t run any sanitizer, oops!
So you have to use ‘host-entry’:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (define-record-type* <host-entry> host-entry
make-host-entry host-entry?
(address host-entry-address)
(canonical-name host-entry-canonical-name
(sanitize assert-valid-name))
(aliases host-entry-aliases
(default '())
(sanitize (cut map assert-valid-name <>))))
scheme@(guile-user)> ,optimize (make-host-entry 1 2 3)
$12 = (make-struct/simple #{% <host-entry> rtd}# 1 2 3)
scheme@(guile-user)> ,optimize (host-entry (address 1) (canonical-name 2))
$13 = (let ((canonical-name (assert-valid-name 2)))
(if (eq? #{% <host-entry> abi-cookie}#
796283273607885551)
(if #f #f)
(throw 'record-abi-mismatch-error
'abi-check
"~a: record ABI mismatch; recompilation needed"
(list #{% <host-entry> rtd}#)
'()))
(let ((aliases ((cut map assert-valid-name <>) '())))
(make-struct/simple
#{% <host-entry> rtd}#
1
canonical-name
aliases)))
--8<---------------cut here---------------end--------------->8---
Also, there’s a naming confusion between ‘host’ and ‘host-entry’; you
should choose one or the other IMO.
Thanks,
Ludo’.
next prev parent reply other threads:[~2023-01-23 22:48 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 [this message]
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
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=87edrkyik8.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 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).