On 2026-01-05 10:36, Ludovic Courtès wrote: > Hi Nicolas! > > Nicolas Graves <[email protected]> skribis: > >> Sadly I've found the use of `with-extensions` in Guix to not be as >> convenient as the use of imported-modules. In particular, we need to >> wrap every `modify-phases` with a call to `with-extensions` when >> `#:modules` contains any package that contains `#:use-module (json)`, >> despite there are a lot of use-cases where the package is not necessary >> (for instance when the python build-side module is imported only for the >> use of the `site-packages` procedure). > > There are two situations I can think of. For build systems that use > Guile-JSON unconditionally, wrap the build system’s gexp (for instance, > that in guix/build-system/pyproject.scm) in ‘with-extensions’. > Apparently this has already been done. > > What are the other cases we’re talking about? Packages that, for > instance, do not use ‘pyproject-build-system’ yet want to be able to > import (guix build-system pyproject-build-system)?
Exactly. > If we’re talking about a dozen packages, adding a ‘with-extensions’ > stanza in those packages seems okay to me. If there’s more, I’m not > sure. I currently count 42 "avoidable" occurrences in my local branch where everything is migrated. They are transmitted in my recent "pyproject migrations" PRs. >> I see two possible directions : >> >> 1) The `#:autoload` way: Use autoloads instead of `#:use-module` in the >> build-systems using `(json)` so that wrapping `with-extensions` is only >> required when it's really used. > > Yes, using #:autoload cannot hurt. I tried that and it works. imported-modules compile with warnings though, I don't know if it's tolerable or not. >> 2) The `#:imported-modules` way: Add an additional keyword argument, >> `#:extensions`, that would be re-injected to avoid the additional >> `with-extensions` around the `modify-phases` gexp. > > That would work too. Did you by chance read https://codeberg.org/guix/guix/issues/1378 ? IMHO, we should plan for such extensibility, and use either of those solutions according to what's more convenient for build-system extensibility goals. -- Best regards, Nicolas Graves
