libguix
Unofficial Rust client library for GNU Guix.
Wraps the guix CLI and its machine-readable REPL (guix repl -t machine) so you can drive package management, system administration, and builds from Rust without parsing human-readable output. Designed for long-running operations: every write returns an Operation with a coalesced event stream and a CancelHandle.
Module map
The module tree mirrors guix --help so navigating the library reads like navigating the CLI:
| Rust | Guix CLI |
|---|---|
Guix::package() → PackageOps |
guix package (install, remove, upgrade, search, show, generations) |
Guix::system() → SystemOps |
guix system reconfigure |
Guix::pull() → PullOps |
guix pull (user catalog + pkexec'd root catalog) |
Guix::gc() → GcOps |
guix gc |
Guix::shell() → ShellOps |
guix shell |
Guix::build() → BuildOps |
guix build |
Guix::describe() → DescribeOps |
guix describe |
Examples
Search and list:
use Guix;
async
Streaming install (REPL-backed, with structured fd-3 events):
use StreamExt;
use ProgressEvent;
let mut op = guix.package.install?;
while let Some = op.events_mut.next.await
op.await_completion.await?;
Run a command in an ad-hoc environment (guix shell):
let op = guix.shell.run?;
op.await_completion.await?;
Build a package and collect its store paths (guix build):
let paths = guix.build.run_to_paths.await?;
for p in paths
Pull the user catalog, or the root catalog under pkexec:
use SystemPullOptions;
let op = guix.pull.user?; // ~/.config/guix/current
let op = guix.pull.as_root?; // /var/guix/profiles/per-user/root
Requirements
A working guix binary on PATH (or at /run/current-system/profile/bin/guix). Tested against modern Guix releases — see MIN_GUIX_VERSION_DATE.
The privileged paths (SystemOps::reconfigure, PullOps::as_root) additionally need polkit actions installed and an authentication agent running in your session. The library returns a structured PolkitFailure error if either is missing.
Features
| Feature | Default | What it does |
|---|---|---|
tracing |
yes | Emit tracing events from the REPL actor and command helpers. |
live-tests |
no | Enables tests that shell out to a real guix on the host. |
blocking |
no | Reserved for a future blocking wrapper API. |
Status
Pre-1.0. The API will shift as the GUI consuming it (in the same repo) grows. Pin a specific version if you depend on it.
License
GPL-3.0-only.