Building Nix derivations
Now that we’ve written our
nix build, which produces a symlink to the result of the derivation at
First, we create a working directory under
cd to it. Then the setup script clears the environment as described in .
The following additional environment variables are also set:
TEMPare all set to the working directory
HOMEare set to nonsense values to prevent impurities
NIX_STOREis set to the path (usually
- Environment variables for each element in
outputscontaining the store path for each output.
Existing matching output paths are removed and locked to prevent build conflicts. Combined stdout and stderr logs are written to
Now the builder is run with
args, and its return code determines the success of the build.
On a successful build, Nix cleans up the working directory, registers dependencies for the outputs, and alters permissions on the outputs to render them immutable.