[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Brainstorming ideas for define-configuration
From: |
Joshua Branson |
Subject: |
Re: Brainstorming ideas for define-configuration |
Date: |
Thu, 09 Mar 2023 09:40:03 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Bruno Victal <mirai@makinata.eu> writes:
> Co-authored-by: Felix Lechner
>
>
> After spending some time with old and new Guix services, I'd like to
> suggest some potential improvements to our define-configuration macro:
>
>
> User-specified sanitizer support
> ===============================================================================
>
Yes please! Thanks for working on these improvements! It would make my
opensmtpd-service updates much easier (though I haven't really touched
the code in a while).
https://issues.guix.gnu.org/56046
>
> The sanitizers should be integrated with the type. Otherwise, they are
> tedious to use and appear verbose when repeatedly applied to multiple fields.
>
> ;; Suggestion #1
> ;; The procedure could return a sanitized value. Upon failure, there are
> ;; the following options:
> ;; - The procedure returns only a special value (akin to %unset-value)
> ;; and an error message, as a pair.
> ;; Exception raising is done by define-sanitized macro behind the scenes
> ;; which makes the procedure easier to write.
> ;; - The procedure raises an exception. There would be no consistency
> ;; on the message formats, however, except for any agreed convention.
> ;; This would involve some code duplication.
> ;; Cons: too specific, not extensible.
>
> (define-sanitized typename procedure
> (prefix ...))
>
>
> ;; Suggestion #2
> ;; A user-supplied procedure ('procname' below) would work just like the
> ;; procedure in option #1.
> ;; There is some similiarity to the Guix record-type*.
> ;; This could be extended more easily in the future should it be required.
> (define-type typename ; maybe call this 'define-configuration-type' ?
> (sanitizer procname)
> (maybe-type? #t)
> ;; The properties below are service specific.
> ;; If this is implemented with Guix record-type* then we could have a
> ;; module containing generic types and do something along the lines of:
> ;; (define-type foo-ip-address
> ;; (inherit generic-ip-address)
> ;; (serializer ...))
> (serializer procname) ; define-type/no-serialization = sets this field
> to #f ?
> (prefix ...))
>
>
> Record Validator
> ===============================================================================
>
> There is also a need to validate records. Matching fields alone do not
> actually
> ensure that the configuration is coherent and usable. For example, some fields
> may be mutually incompatible with others.
>
> We could provide procedures that validate each record type within
> define-configuration itself instead of validating the value at runtime (i.e.
> within the body of the service-type).
This is also a great idea!
> Cheers,
> Bruno
- Brainstorming ideas for define-configuration, Bruno Victal, 2023/03/08
- Re: Brainstorming ideas for define-configuration, Attila Lendvai, 2023/03/09
- Re: Brainstorming ideas for define-configuration,
Joshua Branson <=
- Re: Brainstorming ideas for define-configuration, Liliana Marie Prikler, 2023/03/09
- Re: Brainstorming ideas for define-configuration, Maxim Cournoyer, 2023/03/10
- Re: Brainstorming ideas for define-configuration, jbranso, 2023/03/10
- Re: Brainstorming ideas for define-configuration, Ludovic Courtès, 2023/03/15