From: zimoun <zimon.toutoune@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>, guix-devel@gnu.org
Subject: Re: A plan for parameterized packages
Date: Sun, 15 Nov 2020 18:37:33 +0100 [thread overview]
Message-ID: <86v9e6seqq.fsf@gmail.com> (raw)
In-Reply-To: <87eeku8trb.fsf@gnu.org>
Hi Lduo,
On Sun, 15 Nov 2020 at 17:33, Ludovic Courtès <ludo@gnu.org> wrote:
> That said, this message is about a possible implementation of package
> parameters, so here we go. :-)
Cool!
> To me the requirements for package parameters are:
>
> 1. it must be possible to discover them and choose them from the UI;
>
> 2. they must contain on-line internationalized documentation such that
> the UI can list a package’s parameters and their type;
Except ’boolean’, which kind of type do you have in mind? Aside that
you did not find examples of packages requiring parameters. ;-)
The answer leads to your point #4.
> 3. the chosen parameters when installing a package in a profile must
> be preserved;
You mean track the parameters with ’properties’ in <profile>/manifest,
right?
> 4. it must be possible to enumerate all the possible values of a
> parameter, and thus to build the Cartesian product of all the
> possible parameter combinations of a package (or of a package
> graph!), so we can test those combinations as much as possible.
The values of the option are therefore known at package time, right?
However, this implies restricted possibility for the type, right?
> Subject: [PATCH 1/4] DRAFT Add (guix parameters).
>
> DRAFT: Missing tests & doc.
>
> * guix/parameters.scm: New file.
> * Makefile.am (MODULES): Add it.
> ---
[...]
> diff --git a/guix/parameters.scm b/guix/parameters.scm
> +
> +;; Type of a package parameter.
> +(define-record-type* <parameter-type> parameter-type
> + make-parameter-type
> + parameter-type?
> + (name parameter-type-name) ;debugging purposes only!
> + (string->value parameter-type-string->value)
> + (value->string parameter-type-value->string)
> + (universe parameter-type-universe))
> +
> +(define boolean
> + ;; The Boolean parameter type.
> + (parameter-type (name 'boolean)
> + (universe '(#true #false))
> + (value->string
> + (match-lambda
> + (#f "false")
> + (#t "true")))
> + (string->value
> + (lambda (str)
> + (cond ((string-ci=? str "true")
> + #t)
> + ((string-ci=? str "false")
> + #f)
> + (else
> + (raise (condition
> + (&message (message "wrong value"))))))))))
The types will be “hard-coded“ here, right? Boolean being the simplest
example and imagination just needs to be released, right? :-)
> Subject: [PATCH 2/4] DRAFT transformations: Add '--with-parameter'.
>
> DRAFT: Missing tests & doc.
>
> * guix/transformations.scm (evaluate-parameter-specs)
> (transform-package-parameters): New procedures.
> (%transformations, %transformation-options): Add 'with-parameter'.
> ---
> guix/transformations.scm | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/guix/transformations.scm b/guix/transformations.scm
[...]
> +(define (evaluate-parameter-specs specs proc)
> + "Parse SPECS, a list of strings like \"bitlbee=purple=true\", and return a
> +list of spec/procedure pairs, where (PROC PACKAGE PARAMETER VALUE) is called
> +to return the replacement package. Raise an error if an element of SPECS uses
> +invalid syntax, or if a package it refers to could not be found."
> + (map (lambda (spec)
> + (match (string-tokenize spec %not-equal)
> + ((spec name value)
> + (define (replace old)
> + (proc old name value))
> +
> + (cons spec replace))
> + (_
> + (raise
> + (formatted-message
> + (G_ "invalid package parameter specification: ~s")
> + spec)))))
> + specs))
Here ’proc’ could be anything, right? But then…
> +(define (transform-package-parameters replacement-specs)
> + "Return a procedure that, when passed a package, replaces its direct
> +dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is a list of
> +strings like \"guile-next=stable-3.0\" meaning that packages are built using
> +'guile-next' from the latest commit on its 'stable-3.0' branch."
> + (define (replace old name value)
> + (set-package-parameter-value old name value))
> +
> + (let* ((replacements (evaluate-parameter-specs replacement-specs
> + replace))
> + (rewrite (package-input-rewriting/spec replacements)))
> + (lambda (obj)
> + (if (package? obj)
> + (rewrite obj)
> + obj))))
… it is ’set-package-parameter-value’. It is not clear in my mind.
Does this constrain the hypothetical types?
Cheers,
simon
next prev parent reply other threads:[~2020-11-15 17:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-15 16:33 A plan for parameterized packages Ludovic Courtès
2020-11-15 17:30 ` Nicolò Balzarotti
2020-11-15 17:40 ` Nicolò Balzarotti
2020-11-15 17:44 ` Pierre Neidhardt
2020-11-15 18:09 ` zimoun
2020-11-16 11:50 ` Ludovic Courtès
2020-11-16 12:03 ` Pierre Neidhardt
2020-11-16 14:05 ` zimoun
2020-11-15 17:37 ` zimoun [this message]
2020-11-16 11:54 ` Ludovic Courtès
2020-11-15 18:51 ` Taylan Kammer
2020-11-15 20:46 ` Danny Milosavljevic
2020-11-15 21:16 ` zimoun
2020-11-16 11:25 ` Make mutiple packages from outputs (Was: A plan for parameterized packages) 宋文武
2020-11-16 14:53 ` Make mutiple packages from outputs Ludovic Courtès
2020-11-16 15:10 ` Make mutiple packages from outputs (Was: A plan for parameterized packages) zimoun
2020-11-15 21:24 ` A plan for parameterized packages raingloom
2020-11-16 1:54 ` Ryan Prior
2020-11-16 5:38 ` Clozure size zimoun
2020-11-18 1:30 ` A plan for parameterized packages Denis 'GNUtoo' Carikli
2020-11-20 11:39 ` Ludovic Courtès
2020-11-20 14:38 ` zimoun
2020-11-20 19:44 ` Christopher Baines
2020-11-16 14:51 ` Ludovic Courtès
-- strict thread matches above, loose matches on Subject: below --
2020-11-17 14:25 Stephen Christie
2020-11-17 15:31 ` Ludovic Courtès
2020-11-17 18:13 ` Stephen Christie
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=86v9e6seqq.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/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).