guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal: A new build-system API


From: Mája Tomášek
Subject: Proposal: A new build-system API
Date: Mon, 26 Sep 2022 10:39:41 +0200

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]