Próximo: , Anterior: , Acima: Gerenciamento de pacote   [Conteúdo][Índice]

5.9 Inferiores

Nota: The functionality described here is a “technology preview” as of version 03062c7. As such, the interface is subject to change.

Sometimes you might need to mix packages from the revision of Guix you’re currently running with packages available in a different revision of Guix. Guix inferiors allow you to achieve that by composing different Guix revisions in arbitrary ways.

Technically, an “inferior” is essentially a separate Guix process connected to your main Guix process through a REPL (veja Invocando guix repl). The (guix inferior) module allows you to create inferiors and to communicate with them. It also provides a high-level interface to browse and manipulate the packages that an inferior provides—inferior packages.

When combined with channels (veja Canais), inferiors provide a simple way to interact with a separate revision of Guix. For example, let’s assume you want to install in your profile the current guile package, along with the guile-json as it existed in an older revision of Guix—perhaps because the newer guile-json has an incompatible API and you want to run your code against the old API. To do that, you could write a manifest for use by guix package --manifest (veja Writing Manifests); in that manifest, you would create an inferior for that old Guix revision you care about, and you would look up the guile-json package in the inferior:

(use-modules (guix inferior) (guix channels)
             (srfi srfi-1))   ;for 'first'

(define channels
  ;; This is the old revision from which we want to
  ;; extract guile-json.
  (list (channel
         (name 'guix)
         (url "")

(define inferior
  ;; An inferior representing the above revision.
  (inferior-for-channels channels))

;; Now create a manifest with the current "guile" package
;; and the old "guile-json" package.
 (list (first (lookup-inferior-packages inferior "guile-json"))
       (specification->package "guile")))

On its first run, guix package --manifest might have to build the channel you specified before it can create the inferior; subsequent runs will be much faster because the Guix revision will be cached.

The (guix inferior) module provides the following procedures to open an inferior:

Procedure: inferior-for-channels channels [#:cache-directory] [#:ttl]

Return an inferior for channels, a list of channels. Use the cache at cache-directory, where entries can be reclaimed after ttl seconds. This procedure opens a new connection to the build daemon.

As a side effect, this procedure may build or substitute binaries for channels, which can take time.

Procedure: open-inferior directory [#:command "bin/guix"]

Open the inferior Guix in directory, running directory/command repl or equivalent. Return #f if the inferior could not be launched.

The procedures listed below allow you to obtain and manipulate inferior packages.

Procedure: inferior-packages inferior

Return the list of packages known to inferior.

Procedure: lookup-inferior-packages inferior name [version]

Return the sorted list of inferior packages matching name in inferior, with highest version numbers first. If version is true, return only packages with a version number prefixed by version.

Procedure: inferior-package? obj

Return true if obj is an inferior package.

Procedure: inferior-package-name package
Procedure: inferior-package-version package
Procedure: inferior-package-synopsis package
Procedure: inferior-package-description package
Procedure: inferior-package-home-page package
Procedure: inferior-package-location package
Procedure: inferior-package-inputs package
Procedure: inferior-package-native-inputs package
Procedure: inferior-package-propagated-inputs package
Procedure: inferior-package-transitive-propagated-inputs package
Procedure: inferior-package-native-search-paths package
Procedure: inferior-package-transitive-native-search-paths package
Procedure: inferior-package-search-paths package

These procedures are the counterpart of package record accessors (veja package Reference). Most of them work by querying the inferior package comes from, so the inferior must still be live when you call these procedures.

Inferior packages can be used transparently like any other package or file-like object in G-expressions (veja Expressões-G). They are also transparently handled by the packages->manifest procedure, which is commonly used in manifests (veja the --manifest option of guix package). Thus you can insert an inferior package pretty much anywhere you would insert a regular package: in manifests, in the packages field of your operating-system declaration, and so on.

Próximo: Invocando guix describe, Anterior: Invoking guix time-machine, Acima: Gerenciamento de pacote   [Conteúdo][Índice]