unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: guix-devel@gnu.org
Subject: #:modules and #:imported-modules, and more
Date: Sat, 30 Dec 2023 13:54:59 +0100	[thread overview]
Message-ID: <ZZATI4I5FRvdhpXu@ws> (raw)

[-- Attachment #1: Type: text/plain, Size: 4377 bytes --]

Hello Guix.


Table of Contents
_________________

1. My understanding
2. #:extra-modules, #:extra-imported-modules
3. %...-build-system-modules
4. %default-modules
5. Other comments
.. 1. What are the reasons for the naming scheme of build systems?
6. Conclusion


1 My understanding
==================

  In the process of fixing crashes of libreoffice and netsurf (patches
  coming soon), I was trying to understand the difference between
  #:modules and #:imported-modules.  My conclusion is that the former
  are modules that are (use-modules)-ed automatically, while the latter
  are modules that are made available and can be (use-modules)-ed if
  desired.

  If one wants to add some modules, the way it is done, for
  gnu-build-system, is like this:

  ,----
  | #:imported-modules `((some module)
  |                      ,@gnu-build-system-modules)
  `----

  Is that summary correct?

  Assuming it is, I would like to propose few changes.  I am willing to
  supply the implementation(s), but thought I should discuss it first in
  order not to waste time if it would be a no-go.  They would be done in
  roughly this order over multiple patch series to allow smooth
  transition.


2 #:extra-modules, #:extra-imported-modules
===========================================

  As seen in the example above, currently there is a need to manually
  merge the list of additional modules with the original one.  Failing
  to use the correct base can lead to issues (like crash in netsurf).

  I would like to propose adding two new fields into the build system,
  `#:extra-modules' and `#:extra-imported-modules'.  Those would be
  automatically appended to the `#:modules' and `#:imported-modules',
  removing the need to merge the lists in the package definition.
  Therefore the example above would turn into:

  ,----
  | #:extra-imported-modules '((some module))
  `----

  The original fields would still be available, so full control would be
  possible, if needed.

  There currently seems to be ~276 occurrences of
  `-build-system-modules' in the gnu/packages directory, and vast
  majority of them would be removed.


3 %...-build-system-modules
===========================

  This variable seems misnamed, since it should be used with
  `#:imported-modules', so once the above is done (and the usage of it
  drops down), I would like to rename it to
  `%...-build-system-imported-modules'.


4 %default-modules
==================

  Situation with `#:modules' is more interesting, since there is no
  common pattern.  Some build systems have `%default-modules'
  (non-exported), some just hard-code the list.  In the step above the
  binding was released, so I would like to unify the build systems by
  reusing as public `%...-build-system-modules', which would be used as
  default for `#:modules' in all build systems.

  These steps are somewhat independent, but at least this last one I
  would think would be useful.  Albeit without the previous ones
  different name would have to be used.


5 Other comments
================

5.1 What are the reasons for the naming scheme of build systems?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  It seems that all the build systems use a prefix-based naming scheme,
  so `gnu-build-system', `meson-build-system' and such.  I am curious
  what is the reason for that?  Since Guile modules support `#:prefix',
  would it not be a cleaner choice?

  So I could have something like:

  ,----
  | (define-module (gnu packages foo)
  |   #:use-module ((guix build-system gnu)    #:prefix gnu)
  |   #:use-module ((guix build-system python) #:prefix python))
  |   ...)
  |
  | (define-public bar
  |   (package
  |     ...
  |     (build-system gnu:build-system)))
  |
  | (define-public baz
  |   (package
  |     ...
  |     (build-system python:build-system)))
  `----

  That, given there is a built-in support in the language, seems
  somewhat cleaner.  And could possibly make introspection easier
  (maybe?).  Could someone enlighten me regarding the reasons for the
  current implementation?


6 Conclusion
============

  Thank you for considering this proposal, and thank you in advance for
  any helpful insight you are willing to provide.



Have a nice day,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2023-12-30 12:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-30 12:54 Tomas Volf [this message]
2024-01-09 22:49 ` #:modules and #:imported-modules, and more Ludovic Courtès
2024-01-09 23:09   ` Tomas Volf
2024-01-10 10:23     ` Ludovic Courtès
2024-01-10 16:43       ` Tomas Volf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZZATI4I5FRvdhpXu@ws \
    --to=~@wolfsden.cz \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).