unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New procedure to modify operating-system records
@ 2024-06-23 16:13 Sergio Pastor Pérez
  2024-06-27 13:17 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Sergio Pastor Pérez @ 2024-06-23 16:13 UTC (permalink / raw)
  To: guix-devel; +Cc: michal_atlas+gnu, juli@incana.org

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-30 15:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-23 16:13 New procedure to modify operating-system records Sergio Pastor Pérez
2024-06-27 13:17 ` Ludovic Courtès
2024-06-30 15:23   ` Sergio Pastor Pérez

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).