nix-buildbuild a Nix expressionnix-buildpathsDescriptionThe nix-build command builds the derivations
described by the Nix expressions in paths.
If the build succeeds, it places a symlink to the result in the
current directory. The symlink is called result.
If there are multiple Nix expressions, or the Nix expressions evaluate
to multiple derivations, multiple sequentially numbered symlinks are
created (result, result-2,
and so on).If no paths are specified, then
nix-build will use default.nix
in the current directory, if it exists.nix-build is essentially a wrapper
around nix-instantiate
(to translate a high-level Nix expression to a low-level store
derivation) and nix-store
--realise (to build the store
derivation).The result of the build is automatically registered as
a root of the Nix garbage collector. This root disappears
automatically when the result symlink is deleted
or renamed. So don’t rename the symlink.OptionsAdd a symlink in the current directory to the
store derivation produced by nix-instantiate.
The symlink is called derivation (which is
numbered in the case of multiple derivations). The derivation is
a root of the garbage collector until the symlink is deleted or
renamed.Do not create a symlink to the output path. Note
that as a result the output does not become a root of the garbage
collector, and so might be deleted by nix-store
--gc.