[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Apply a patch to a given package definition
From: |
Simon Tournier |
Subject: |
Re: Apply a patch to a given package definition |
Date: |
Tue, 27 Aug 2024 16:19:53 +0200 |
Hi,
On Tue, 20 Aug 2024 at 11:15, Christoph Buck <dev@icepic.de> wrote:
> By chance, do you know if a transformation would also work and if so,
> how?
Yes. Roughly and quickly, ’inherit’ is only a macro that copies all the
record fields. Other said,
(package
(inherit foo)
…)
creates a new ’package’ record where all the fields of ’foo’ are copied
expect the ones defined by ’…’. Therefore, that defines a package and
this package can be manipulated as any other packages.
At the command-line, the derivations of one package and the same with
a transformation.
--8<---------------cut here---------------start------------->8---
$ guix build -d hello
/gnu/store/qr00sgbh3vwwqswmgjjymg6wkys9r4i2-hello-2.12.1.drv
$ guix build -d hello --without-tests=hello
/gnu/store/rfxhb9z4vrdp1hhhq96qh13wyfkrmapf-hello-2.12.1.drv
--8<---------------cut here---------------end--------------->8---
Using the REPL, let start with the case where all the fields are copied
without any modification.
--8<---------------cut here---------------start------------->8---
$ guix repl
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guix-user)> ,use(gnu packages base)
scheme@(guix-user)> ,use(guix packages)
scheme@(guix-user)> (define hey (package (inherit hello)))
scheme@(guix-user)> hey
$1 = #<package hello@2.12.1 7ee70718a790>
--8<---------------cut here---------------end--------------->8---
As you can see, the variable ’hey’ is just a ’package’. And since all
the record fields are the same as the ones of ’hello’, the both
derivations are exactly the same.
--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,lower hey
$2 = #<derivation /gnu/store/qr00sgbh3vwwqswmgjjymg6wkys9r4i2-hello-2.12.1.drv
=> /gnu/store/6fbh8phmp3izay6c0dpggpxhcjn4xlm5-hello-2.12.1 7ee6f93cd050>
scheme@(guix-user)> ,lower hello
$3 = #<derivation /gnu/store/qr00sgbh3vwwqswmgjjymg6wkys9r4i2-hello-2.12.1.drv
=> /gnu/store/6fbh8phmp3izay6c0dpggpxhcjn4xlm5-hello-2.12.1 7ee6f93cd050>
--8<---------------cut here---------------end--------------->8---
So far so good! Now, let apply some transformation as described in the
manual by “(guix) Defining Package Variants” [1].
--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,use(guix transformations)
scheme@(guix-user)> (define (transform p) ((options->transformation
`((without-tests . ,(package-name p)))) p))
scheme@(guix-user)> (package-arguments (transform hey))
$4 = (#:tests? #f)
--8<---------------cut here---------------end--------------->8---
And the derivation reads:
--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> (transform hey)
$5 = #<package hello@2.12.1 guix/transformations.scm:1098 7ee7071856e0>
scheme@(guix-user)> ,lower $5
$6 = #<derivation /gnu/store/rfxhb9z4vrdp1hhhq96qh13wyfkrmapf-hello-2.12.1.drv
=> /gnu/store/w6003221bya21djwrbp9adqyykhsljii-hello-2.12.1 7ee6f8921550>
--8<---------------cut here---------------end--------------->8---
Which is the same as above.
Hope that helps,
simon
1: https://guix.gnu.org/manual/devel/en/guix.html#Defining-Package-Variants