all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Proposal: A new build-system API
@ 2022-09-26  8:39 Mája Tomášek
  2022-09-26 10:49 ` zimoun
  0 siblings, 1 reply; 4+ messages in thread
From: Mája Tomášek @ 2022-09-26  8:39 UTC (permalink / raw)
  To: guix-devel


Hello guix,

I have been lately trying to write a build system or two. And I have
found myself in a weird situation. The current API documentation is
lackluster and the API itself isn't really ergonomic.

First, I need to clarify that I understand that there is a lack of
documentation, it is completely acceptable, but as I didn't really get
the build system API, it was hard for me to grasp the intrices.

Second, I appologize if I am touching on a conversation that already
happened before, but I couldn't find it in the guix devel mailing list,
as there were too many hits when I searched.

Third, this API change would cause breakage of the old, so it isn't
without a compromise, I think it could be done with a deprecation, but
it would be, in my opinion, difficult.

Currently the package and build system APIs don't mesh together well.

(package
        ...
        (inputs list-of-inputs)
        (build-system some-build-system)
        (arguments (list-of-quoted #:key value))
        ...
        )

What would I propose? To design the build system API similiarly as the
package API. With records.

For a simple package, almost nothing would change:

(package
        ...
        (inputs list-of-inputs)
        (build-system (some-build-system))
        ...
        )

But for a more complex package:

(package
        ...
        (inputs list-of-inputs)
        (build-system
                (some-build-system
                        (phases new-list-of-phases)
                        (strip-binaries? #f)))
        ...
        )

This would be the user-facing API, as for the build system developer
API for a simple build system:

(define-build-system some-build-system
                     (inherit gnu-build-system)
                     (name 'some)
                     (description "Some build system")
                     (phases %standard-phases)
                     (strip-binaries? #t)
                     ...
                     (builder (thunked)
                              (build-system->builder this-build-system))
)

The build-system->builder method would generate the build, with
arguments properly adjusted, records translated into keyword arguments,
for a standard build system, the alternative,
would be to provide a (lambda (build-system)
some-code-that-returns-derivation).

The current system is good, but when you need to write your own build
system, you needlessly need to write thins like ungexping arguments,
running gexp->derivation, which is really the system by which the guix
daemon operates, but which could really be abstracted away from the
build system developer. The code writing for a complete build system is repetetive
and complicated.

I don't know, if I have missed some things, this could be a really bad
proposal, and if it is, feel free to ignore it. I have tried to come up
with something new, and I am not the most profficient with either guix
or guile. This was my shot at trying to be helpful in something bigger
than updating packages or fixing small service bugs.

With wishes of the best of luck,
Maya

PS. I appologize for spelling errors.


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

end of thread, other threads:[~2022-09-27  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26  8:39 Proposal: A new build-system API Mája Tomášek
2022-09-26 10:49 ` zimoun
2022-09-26 18:07   ` Mája Tomášek
2022-09-27  7:56     ` Philip McGrath

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.