Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Extending Guix

Guix is focused on empowering users, so it's expected that one can expand its functionality with new commands. To view the available commands in your present Guix installation, utilize the help command. If your system is recent, numerous extensions are at your disposal, available as individual packages or a meta-package containing a collection of extensions. To use them, execute the command: guix extensions.

To address the need for the help menu to include information about available extensions, a change was made. Guix locates extensions by searching GUIX_EXTENSIONS_PATH. Recently, Guix introduced a new method for writing extensions. Previously, extensions were searched under /path/to/guix/extensions, with module names following the pattern (guix extensions NAME).

The new schema places extensions under /path/to/SCHEMA_VERSION; the module name remains (guix extensions NAME). The advantage of the new schema is that Guix can treat the extension module as a standard Guile module, allowing the runtime to find the compiled .go file of the extension. The old schema relied on runtime evaluation, and the load machinery couldn't handle compiled files.

This change significantly improves performance, so it's recommended to update any old extensions to the new schema.

To create a basic extension, start by setting up the project structure. Create directories for the extension in the project root. Then, create the file guix/extensions/hello.scm with the necessary contents. Import (guix scripts) to access the define-command macro and declare the command for export. With this, the extension is functional. To make it discoverable by users, add a help message that displays it in the guix help menu using (srfi srfi-37) for option parsing and (guix ui) for internationalized strings.

While there is no dedicated Guix build-system for extensions at the moment, the guile-build-system works well for this purpose. Create a guix.scm file at the project root with the appropriate package definition. The flags passed to guix shell for testing the extension are as follows. The example extension uses the new extension scheme, so the guix command must be at or newer than commit de069958fc.

This introduction to Guix extensions aims to encourage readers to write their own extensions and contribute them to the guix-extensions Codeberg organization as a central hub for community development.

Rewritten by urgent.news; may contain errors — check the original.

Source: guix.gnu.org

Read the original at guix.gnu.org →

Report a problem with this story

More in Tech

Beauty in DVD Menus

Article URL: https://vale.rocks/posts/dvd-menus Comments URL: https://news.ycombinator.com/item?id=50005527 Points: 240 # Comments: 144

More from Thursday 8 October →