On Friday, April 10, 2026 5:59:57 PM India Standard Time Jason Conroy wrote:
> I've encountered two ways to alter the visibility of a package,
> and I'm curious about their differences and intended uses.
> 
> A package with a `hidden?` property (e.g. `(properties '((hidden?
> . #t)))`) is invisible to common interactive commands like `guix
> package -s` or `guix build <package_name>`. Similarly, some of
> Guix's Scheme interfaces like `fold-packages` ignore hidden
> packages by default.
> 
> On the other hand, unexported module bindings (e.g. packages bound
> using `define` instead of `define-public`) also appear hidden when
> using interactive commands. I'm not sure whether Scheme APIs also
> treat them specially.
> 
> I have observed one semantic difference between the two, and
> sometimes it's a bit of a gotcha: when inheriting from a package
> that sets the `hidden?` property, the child package will also be
> hidden unless it explicitly clears the property, regardless of how
> its module binding is defined. Since this package property is
> pretty rare, it's an easy one to miss.
> 
> So I'd like to know: what are the best practices for these two
> related features? Unfortunately I wasn't able to find much info in
> the manual.
> 
> Cheers,
> 
> Jason
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.

-- 
-----
Sughosha

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to