Hello Guix. Some time ago, I disclosed on this mailing list that I was working on a procedure to facilitate modifications of Guile records. The idea was to be able to easily apply transformations to all `operating-system` record packages.
I received a lot of help from Michal Atlas and Juliana Sims. Both of them are active members of this community, and I'm very grateful for how welcoming the have been. I'm writing this mail from a system that grafts `mesa` for the `nvidia-driver` available in [1]. Although I'm aware that this is not the place to discuss proprietary stuff, this is not about running an NVIDIA system. This enables any Guix user to arbitrarily replace packages system-wide. One could replace `glibc` for `glibc-custom`. I'm using the NVIDIA graft as an example because it's what I have at hand that would test that the graft applies system-wide effectively. The procedure allows the user to apply a function to all elements of a collection that match a certain type. With this new procedure one could write something like this: --8<---------------cut here---------------start------------->8--- (map-type (lambda (_) (@ (gnu packages games) cowsay)) (@ (guix packages) <package>) my-operating-system) --8<---------------cut here---------------end--------------->8--- Which will replace every package on the system for the `cowsay` package. Albeit a cowsified OS will not be very useful, other kinds of transformations could greatly simplify OS definitions. It would make it very convenient to deploy systems with grafts on important libraries that are dependencies of many packages. A more useful example would be this syntax rule: --8<---------------cut here---------------start------------->8--- (define-syntax-rule (custom-libc-operating-system exp ...) "Like 'operating-system' but graft 'libc' with the a custom 'libc' package." (map-type replace-libc (@ (guix packages) <package>) (operating-system exp ...))) --8<---------------cut here---------------end--------------->8--- Which, if `replace-libc` grafts your custom libc using `package-input-rewriting`, would allow you to define a system like so: --8<---------------cut here---------------start------------->8--- (custom-libc-operating-system ...) --8<---------------cut here---------------end--------------->8--- Is Guix interested in having such a procedure? If not, I will submit it to Nonguix but I believe it would be a welcomed addition for Guix users. In the case that the Guix community is interested where should it be placed? I was thinking `guix/records.scm`, what do you think? The complete implementation can be found in my personal channel [2]. [1] https://gitlab.com/nonguix/nonguix [2] https://codeberg.org/shepherd/omega/src/commit/0d45b10f709cfbc70c3ec756933f09a296a9d6e3/pastor/utils/gpu-specification.scm#L51 Have a nice day! Sergio.