meta_package_manager.managers.guix module¶

class meta_package_manager.managers.guix.Guix[source]¶

Bases: PackageManager

GNU Guix, GNU’s functional package manager.

Note

All operations target the current user’s default profile. Declarative system configuration (Guix System config.scm) is not covered.

Guix is a rolling release with no upstream semver to pin against: guix --version reports a release tag, a git describe string, or the bare commit hash of an in-tree checkout. No requirement floor is enforced, since any working guix will do.

Warning

search evaluates every package definition to match the query, so its cost scales with the size of the package set, not the result count: tens of seconds on a freshly pulled Guix, longer still from an in-tree development checkout. The call is bounded by mpm --timeout (120s by default), past which it is killed with no results returned, so a slow search can look like a hang.

Initialize cli_errors list.

name: str = 'GNU Guix'¶

Return package manager’s common name.

Default value is based on class name.

homepage_url: str | None = 'https://guix.gnu.org'¶

Home page of the project, only used in documentation for reference.

Slug of the brand mark standing for this manager in the documentation.

Names an SVG vendored under docs/assets/managers/, whose provenance and license are recorded in docs/assets/managers/logos.yaml. Inlined at the top of the manager’s page by meta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.

Several managers legitimately share one slug, either because they wrap the same upstream (brew and cask) or because the tool has no mark of its own and its ecosystem’s stands in (apt under Debian’s swirl, cargo under Rust’s gear). Documentation-only, like homepage_url: no CLI output reads it.

platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='almalinux', name='AlmaLinux'), Platform(id='alpine', name='Alpine Linux'), Platform(id='altlinux', name='ALT Linux'), Platform(id='amzn', name='Amazon Linux'), Platform(id='android', name='Android'), Platform(id='arch', name='Arch Linux'), Platform(id='buildroot', name='Buildroot'), Platform(id='cachyos', name='CachyOS'), Platform(id='centos', name='CentOS'), Platform(id='chromeos', name='ChromeOS'), Platform(id='clearlinux', name='Clear Linux OS'), Platform(id='cloudlinux', name='CloudLinux OS'), Platform(id='debian', name='Debian'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='kali', name='Kali Linux'), Platform(id='kvmibm', name='KVM for IBM z Systems'), Platform(id='linuxmint', name='Linux Mint'), Platform(id='mageia', name='Mageia'), Platform(id='mandriva', name='Mandriva Linux'), Platform(id='manjaro', name='Manjaro Linux'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='parallels', name='Parallels'), Platform(id='pidora', name='Pidora'), Platform(id='pikaos', name='PikaOS'), Platform(id='raspbian', name='Raspbian'), Platform(id='rhel', name='RedHat Enterprise Linux'), Platform(id='rocky', name='Rocky Linux'), Platform(id='scientific', name='Scientific Linux'), Platform(id='slackware', name='Slackware'), Platform(id='sles', name='SUSE Linux Enterprise Server'), Platform(id='slitaz', name='SliTaz GNU/Linux'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='tuxedo', name='Tuxedo OS'), Platform(id='ubuntu', name='Ubuntu'), Platform(id='ultramarine', name='Ultramarine'), Platform(id='void', name='Void Linux'), Platform(id='wsl1', name='Windows Subsystem for Linux v1'), Platform(id='wsl2', name='Windows Subsystem for Linux v2'), Platform(id='xenserver', name='XenServer')})¶

List of platforms supported by the manager.

Allows for a mishmash of platforms and groups of platforms. Will be normalized into a frozenset of Platform instances at instantiation.

version_regexes: tuple[str, ...] = ('guix \\(GNU Guix\\) (?P<version>\\d[\\w.\\-+]*)', 'guix \\(GNU Guix\\) (?P<version>[0-9a-f]{7,40})\\b')¶
$ guix --version
guix (GNU Guix) 1.4.0
property installed: Iterator[Package]¶

Fetch installed packages.

Output is tab-separated: name, version, output, store path.

$ guix package --list-installed
hello   2.10    out     /gnu/store/k74skdjjb9c9zqjv9nmgd6zi92wpf3q0-hello-2.10
python  3.10.7  out     /gnu/store/2n3g8n7d5xkp6h4qz1v8m0rjc9wf5aby-python-3.10.7
property outdated: Iterator[Package]¶

Fetch outdated packages.

Relies on guix upgrade --dry-run which lists every package that would be upgraded without modifying the user profile.

$ guix upgrade --dry-run
The following packages would be upgraded:
   hello 2.12.1 → 2.12.3
   sed   4.8 → 4.9
search(query, extended, exact)[source]¶

Fetch matching packages.

Caution

Search does not support extended or exact matching. So we return the best subset of results and let meta_package_manager.manager.PackageManager.refiltered_search() refine them.

Caution

guix search loads and evaluates every package definition to match the query against each package’s name, synopsis, and description, so it is inherently slow: its cost scales with the size of the package set, not the number of results. A single search runs for tens of seconds on a freshly pulled Guix, and far longer from an in-tree dev checkout that recompiles modules on the fly. The call is bounded by mpm --timeout; when that is unset, search uses the 120s read-only default, past which the process is killed and no results are returned, so a slow search can look like a hang.

Results are printed in recutils format with records separated by blank lines.

$ guix search hello
name: hello
version: 2.10
outputs: out
systems: x86_64-linux i686-linux
dependencies: [email protected] ...
location: gnu/packages/base.scm:86:2
homepage: https://www.gnu.org/software/hello/
license: GPL 3+
synopsis: Hello, GNU world: an example GNU package
description: GNU Hello prints the message "Hello, world!"
+ and then exits.  It serves as an example of standard
+ GNU coding practices.
relevance: 10
Return type:

Iterator[Package]

install(package_id, version=None)[source]¶

Install one package.

$ guix install hello
Return type:

str

upgrade_all_cli()[source]¶

Generates the CLI to upgrade all packages.

$ guix upgrade
Return type:

tuple[str, ...]

upgrade_one_cli(package_id, version=None)[source]¶

Generates the CLI to upgrade one package.

$ guix upgrade hello
Return type:

tuple[str, ...]

cli_names: tuple[str, ...] = ('guix',)¶

List of CLI names the package manager is known as.

This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.

..hint::

This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named python or python3.

By default, this property’s value is derived from the manager’s ID (see the MetaPackageManager.__init__ method above).

id: str = 'guix'¶

Package manager’s ID.

Derived by defaults from the lower-cased class name in which underscores _ are replaced by dashes -.

This ID must be unique among all package manager definitions and lower-case, as they’re used as feature flags for the mpm CLI.

remove(package_id)[source]¶

Remove one package.

$ guix remove hello
Return type:

str

virtual: bool = False¶

Should we expose the package manager to the user?

Virtual package manager are just skeleton classes used to factorize code among managers of the same family.

sync()[source]¶

Fetch the latest Guix channel revisions.

$ guix pull
Return type:

None

cleanup_cache()[source]¶

Collect garbage in the store.

$ guix gc
Return type:

None