From: Simon Tournier <zimon.toutoune@gmail.com>
To: Christoph Buck <dev@icepic.de>, Ian Eure <ian@retrospec.tv>
Cc: help-guix@gnu.org
Subject: Re: Apply a patch to a given package definition
Date: Tue, 27 Aug 2024 16:19:53 +0200 [thread overview]
Message-ID: <87a5gy82uu.fsf@gmail.com> (raw)
In-Reply-To: <87ed6jy2pj.fsf@icepic.de>
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
prev parent reply other threads:[~2024-08-27 14:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 8:19 Apply a patch to a given package definition Christoph Buck
2024-08-19 23:02 ` Ian Eure
2024-08-20 9:15 ` Christoph Buck
2024-08-20 21:15 ` Ian Eure
2024-08-27 14:19 ` Simon Tournier [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5gy82uu.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=dev@icepic.de \
--cc=help-guix@gnu.org \
--cc=ian@retrospec.tv \
/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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.