[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type.
From: |
Ludovic Courtès |
Subject: |
[bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type. |
Date: |
Mon, 23 Jan 2023 23:47:35 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
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’.
- [bug#60735] [PATCH 2/2] services: Add block-facebook-hosts-service-type., (continued)
[bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type., Ludovic Courtès, 2023/01/23
[bug#60735] [PATCH v2 1/3] services: Add etc-hosts-service-type.,
Ludovic Courtès <=
[bug#60735] [PATCH v3 1/3] services: Add hosts-service-type., Bruno Victal, 2023/01/27