Sughosha <[email protected]> writes:
The difference between `define` and `define-public` is that
`define` does not
export the variable but `define-public` does. Since the
variables that use just
`define` does not make it available in other modules, unless
exported by
`(export VARIABLE ...)` or useed by `(@@ (gnu packages MODULE)
VARIABLE)`,
even if they include the module it is defined in. Whereas
`define-public` also
exports the variable making it available in the modules that use
the module it
is defined in, without the need to export again.
Some variables are intended only for a specific package (for
example,
`%chromium-version` or `%ungoogled-origin`) and are not required
in any other
package or module. So they are just `define`d. But normally
package variables
are defined publicly so that they can be used as inputs in other
packages.
Hidden packages are usually not meant for users to install
directly but for
using as inputs of other packages. If they are defined publicly,
they can be
used as dependencies by other packages. For example, there are
`glib` and
`glib-with-documentation`. Normally if an end user installs
`glib` by using
`guix package --install glib`, they are typically installing the
`glib-with-
documentation` package, without excluding the documentation. But
other
packages using `glib` as an input do not need the
documentation. They only
need the libraries to link. This saves around 75M space in
total.
So, `glib` is hidden but defined publicly so that the packages
in other modules
can also use it as an input, without needing to export again. It
is hidden
because it is not meant for end users to install it, while
`glib-with-
documentation` is for the end users.
Thanks for the reply. I'm reasonably familiar with the visibility
levels of module bindings, but for me the surprising part was that
visibility also changes Guix's runtime behavior in nontrivial
ways. This suggests that the registry is built by applying some
kind of introspection to the package modules themselves.
In most other languages this introspection wouldn't be practical,
but it appears that this is exactly what happens
here. `fold-packages` ultimately calls `module-map`, an
undocumented Guile function that iterates over the key/value pairs
of a module's hash table.
Thanks for the useful example of a package that's highly visible
as an input but not as a leaf.
Jason