Up: Utilities


5.1 Invoking guix-build

The guix-build command builds packages or derivations and their dependencies, and prints the resulting store paths. 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, or a derivation such as /nix/store/xxx-coreutils-8.19.drv. Alternatively, the --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 needed.

The options may be zero or more of the following:

--expression=expr
-e expr
Build the package expr evaluates to.

For example, expr may be (@ (distro packages guile) guile-1.8), which unambiguously designates this specific variant of version 1.8 of Guile.

--source
-S
Build the packages' source derivations, rather than the packages themselves.

For instance, guix-build -S gcc returns something like /nix/store/xxx-gcc-4.7.2.tar.bz2, which is GCC's source tarball.

--system=system
-s system
Attempt to build for system—e.g., i686-linux—instead of 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.

--derivations
-d
Return the derivation paths, not the output paths, of the given packages.
--keep-failed
-K
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.
--dry-run
-n
Do not build the derivations.
--no-substitutes
Build instead of resorting to pre-built substitutes.
--cores=n
-c n
Allow the use of up to n CPU cores for the build. The special value 0 means to use as many CPU cores as available.
--root=file
-r file
Make file a symlink to the result, and register it as a garbage collector root.
--verbosity=level
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.

Behind the scenes, guix-build is essentially an interface to the package-derivation procedure of the (guix packages) module, and to the build-derivations procedure of the (guix store) module.