Subject: [bug#44321] [PATCH 6/6] doc: Add "Defining Package Variants" section.

From: Ludovic Courtès <[email-masked]>
Date: Sat, 31 Oct 2020 11:14:55 +0100

Hi,

zimoun <[email-masked]> skribis:

> On Fri, 30 Oct 2020 at 00:10, Ludovic Courtès <[email-masked]> wrote:
>
>> -* Invoking guix repl::          Programming Guix in Guile.
>> +* Invoking guix repl::          Programming Guix in Guile
>
> This change is already in commit 729d4ba025bc8556d00041f9af5b6609eeec9d80.

OK, I’ll have to rebase and regenerate the menus maybe.

>> +You can just as well define variants with a different set of
>> +dependencies than the original package.  For example, the default
>> +@code{gdb} package depends on @code{guile}, but since that is an
>> +optional dependency, you can define a variant that removes that
>> +dependency like so:
>> +
>> +@lisp
>> +(use-modules (gnu packages gdb)    ;for 'gdb'
>> +             (srfi srfi-1))        ;for 'alist-delete'
>> +
>> +(define gdb-sans-guile
>> +  (package
>> +    (inherit gdb)
>> +    (inputs (alist-delete "guile"
>> +                          (package-inputs gdb)))))
>> +@end lisp
>
> Does it make sense to add a sentence explaining that the “guile” is the
> name provided by the string in the ’inputs’ list of the package ’gdb’,

Yeah, I’ll add a sentence like:

+The @code{alist-delete} call above removes the tuple from the
+@code{inputs} field that has @code{"guile"} as its first element
+(@pxref{SRFI-1 Association Lists,,, guile, GNU Guile Reference
+Manual}).

>> +@deffn {Scheme Procedure} options->transformation @var{opts}
>> +Return a procedure that, when passed an object to build (package,
>> +derivation, etc.), applies the transformations specified by @var{opts} and returns
>> +the resulting objects.  @var{opts} must be a list of symbol/string pairs such as:
>> +
>> +@example
>> +((with-branch . "guile-gcrypt=master")
>> + (without-tests . "libgcrypt"))
>> +@end example
>
> Is it on purpose that here you use ’without-tests’ and then…

[...]

> …you use ’with-debug-info’ as example?

Yeah, the two examples are independent of one another so I guess it’s
fine to have some diversity, no?

>> +@lisp
>> +(define libressl-instead-of-openssl
>> +  ;; Replace all the packages called "openssl" with LibreSSL.
>> +  (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
>> +@end lisp
>
> It is already in the manual but why this ’const’?

Because ‘package-input-rewriting/spec’ takes a list of spec/procedure
pairs.

Thanks!

Ludo’.