unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Ian Eure <ian@retrospec.tv>
To: Christoph Buck <dev@icepic.de>
Cc: help-guix@gnu.org
Subject: Re: Apply a patch to a given package definition
Date: Mon, 19 Aug 2024 16:02:10 -0700	[thread overview]
Message-ID: <87ikvw3y2u.fsf@meson> (raw)
In-Reply-To: <87sev0sz4k.fsf@icepic.de>

Hi Christoph,

Christoph Buck <dev@icepic.de> writes:

> Hi!
>
> How do i define a new package which is just a variation of a 
> given
> package defined in guix?
>
> In my concrete example i try to add a new board definition file 
> via a
> patch to the u-boot bootloader. What i come up with, looks like 
> this:
>
> ```
> ;; Defines a package ub which will compile u-boot for the
> ;; `new-cool-board` description file
>
> (define ub (make-u-boot-package "new-cool-board" 
> "arm-linux-gnueabihf"))
>
> (define-public u-boot-new-cool-board-arm
>   (package
>     (inherit ub)
>     (version "2024.01")
>     (source (origin
>               (patches 
>               '("0001-Add-board-description-for-new-cool-board.patch"))
>               (method url-fetch)
>               (uri (string-append
>                     "https://ftp.denx.de/pub/u-boot/"
>                     "u-boot-" version ".tar.bz2"))
>               (sha256
>                (base32
>                 "1czmpszalc6b8cj9j7q6cxcy19lnijv3916w3dag6yr3xpqi35mr"))))))
>
> ```
>
> I create a u-boot variant for my "new-cool-board" using the 
> build in
> `make-u-boot-package` function, then i define a new package and 
> inherit
> from the package variant created with the `make-u-boot-package`
> function. Then i overwrite `source` entry with an entry which 
> also
> applies my patch file. This works, however the original u-boot 
> package
> also apply some patches, which are now lost and must manually 
> added by
> me again. This seems rather error prone. Is there a better 
> solution?
>

You can have your source inherit from the original package’s, but 
with modifications -- just like the package itself.  This might 
not be exaxtly right, but should give you the right idea:

    (define-public u-boot-new-cool-board-arm
      (package
        (inherit ub)
        (version "2024.01")
        (source
         (origin
           (inherit (package-source ub))
           (patches (append (origin-patches (package-source ub))
                            '("0001-Add-board-description-for-new-cool-board.patch")))))))

Any fields you don’t want to modify will be inherited, so you may 
be able to eliminate the version field as well.

  — Ian


  reply	other threads:[~2024-08-19 23:14 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 [this message]
2024-08-20  9:15   ` Christoph Buck
2024-08-20 21:15     ` Ian Eure
2024-08-27 14:19     ` Simon Tournier

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=87ikvw3y2u.fsf@meson \
    --to=ian@retrospec.tv \
    --cc=dev@icepic.de \
    --cc=help-guix@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.
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).