Hi Christoph,

Christoph Buck <d...@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 via email to