guix build command builds packages or derivations and
their dependencies, and prints the resulting store paths. Note that it
does not modify the user’s profile—this is the job of the
guix package command (see Invoking guix package). Thus,
it is mainly useful for distribution developers.
The general syntax is:
guix build options package-or-derivation…
package-or-derivation may be either the name of a package found in
the software distribution such as
coreutils-8.20, or a derivation such as
/gnu/store/…-coreutils-8.19.drv. In the former case, a
package with the corresponding name (and optionally version) is searched
for among the GNU distribution modules (see Package Modules).
--expression option may be used to specify a
Scheme expression that evaluates to a package; this is useful when
disambiguation among several same-named packages or package variants is
The options may be zero or more of the following:
Build the package or derivation expr evaluates to.
For example, expr may be
(@ (gnu packages guile)
guile-1.8), which unambiguously designates this specific variant of
version 1.8 of Guile.
Alternately, expr may be a G-expression, in which case it is used
as a build program passed to
Lastly, expr may refer to a zero-argument monadic procedure
(see The Store Monad). The procedure must return a derivation as a
monadic value, which is then passed through
Build the packages’ source derivations, rather than the packages themselves.
guix build -S gcc returns something like
/gnu/store/…-gcc-4.7.2.tar.bz2, which is GCC’s source tarball.
The returned source tarball is the result of applying any patches and
code snippets specified in the package’s
origin (see Defining Packages).
Attempt to build for system—e.g.,
the host’s system type.
An example use of this is on Linux-based systems, which can emulate
different personalities. For instance, passing
--system=i686-linux on an
x86_64-linux system allows users
to build packages in a complete 32-bit environment.
Cross-build for triplet, which must be a valid GNU triplet, such
"mips64el-linux-gnu" (see GNU
configuration triplets in GNU Configure and Build System).
Use source as the source of the corresponding package.
source must be a file name or a URL, as for
download (see Invoking guix download).
The “corresponding package” is taken to be one specified on the
command line whose name matches the base of source—e.g., if
/src/guile-2.0.10.tar.gz, the corresponding
guile. Likewise, the version string is inferred from
source; in the previous example, it’s
This option allows users to try out versions of packages other than the
one provided by the distribution. The example below downloads
ed-1.7.tar.gz from a GNU mirror and uses that as the source for
guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
As a developer,
--with-source makes it easy to test release
guix build guile --with-source=../guile-188.8.131.52-e1bb7.tar.xz
Return the derivation paths, not the output paths, of the given packages.
Make file a symlink to the result, and register it as a garbage collector root.
Return the build log file names for the given package-or-derivations, or raise an error if build logs are missing.
This works regardless of how packages or derivations are specified. For instance, the following invocations are equivalent:
guix build --log-file `guix build -d guile` guix build --log-file `guix build guile` guix build --log-file guile guix build --log-file -e '(@ (gnu packages guile) guile-2.0)'
In addition, a number of options that control the build process are
guix build and other commands that can spawn builds,
guix package or
guix archive. These are the
Keep the build tree of failed builds. Thus, if a build fail, its build tree is kept under /tmp, in a directory whose name is shown at the end of the build log. This is useful when debugging build issues.
Do not build the derivations.
When substituting a pre-built binary fails, fall back to building packages locally.
Do not use substitutes for build products. That is, always build things locally instead of allowing downloads of pre-built binaries (see Substitutes).
Do not attempt to offload builds via the daemon’s “build hook” (see Daemon Offload Setup). That is, always build things locally instead of offloading builds to remote machines.
When the build or substitution process remains silent for more than seconds, terminate it and report a build failure.
Likewise, when the build or substitution process lasts for more than seconds, terminate it and report a build failure.
By default there is no timeout. This behavior can be restored with
Use the given verbosity level. level must be an integer between 0 and 5; higher means more verbose output. Setting a level of 4 or more may be helpful when debugging setup issues with the build daemon.
Allow the use of up to n CPU cores for the build. The special
0 means to use as many CPU cores as available.
Behind the scenes,
guix build is essentially an interface to
package-derivation procedure of the
module, and to the
build-derivations procedure of the