Subject: [bug#77072] [PATCH v1] channels: add transformer field

From: Rutherther <[email-masked]>
Date: Sat, 22 Mar 2025 11:13:10 +0100

Hello Jakob,

I also encountered this issue and would like a way to transform
channels. However, I have a few notes.

While looking through the code I noticed latest-channel-instance
has an argument called patches. This argument is already capable of
applying patches. Each patch has a predicate and application function,
First the predicate is ran to know if the patch is applicable,
and if so, then it's applied with the application function.

Wouldn't it make sense to rather than making a new mechanism,
extend the current one, by adding to channels a new field
that will hold list of `patch` records, and then in
latest-channels-instance we would just do

```
(apply-patches checkout commit (channel-patches patches))
```

?

Apart from that I am wondering if this is going to be user friendly,
because I would imagine most people will just want to patch with already
existing commits. And for that it would be much easier to just have a
list of files to apply, similar to what origin has.
While this will be possible with this transformer field, it will mean
calling the patch (or I could've missed a function that does that
already).
So maybe at least exposing a new procedure to apply a list of patches
would be good, so users can then just do something like:

```
(channel
  (patches ;; already expecting list of patch records
    (make-channel-patches
      (list (local-file "fix-1.patch")))))
```
Where make-channel-patches takes a list of files
and returns a patch record returning #t for predicate,
and applying by calling the patch executable for each file, similarly
to what patch-and-repack in guix/packages.scm does.
Note that I am not sure if local-file is appropriate here
or if gexps are unusable.

What do you think?

Regards,
Rutherther