In the manual it is written :
The command
nix-instantiategenerates store derivations from (high-level) Nix expressions.
What is nix-instantiate good for ?
The command nix-instantiate sole purpose is to evaluate Nix expressions.
The primary purpose of the Nix languages is to generate derivations.
What is a store-derivation?
A derivation (see example) is a computer-friendly representation of the build recipes used for building (realize) packages. They are files with the extension .drv which are listed in the store directory, usually /nix/store.
These build recipes are understood by the Nix daemon, and are used to ensure that all the dependencies are built before, and stored in the pre-computed paths. Once all dependencies are successfully compiled, then the Nix daemon can look for substitute, or realize the derivation locally. All the detailed explanation is available in Eelco Dolstra PhD Thesis.
These files are created each time the nix-instantiate command evaluates the derivation function of the Nix language, unless the --eval command line option is provided.
Why one would generate store derivations using
nix-instantiate?
If you are interested in the build output, you should prefer nix-build, which is equivalent to:
$ nix-store -r $(nix-instantiate '
In some cases you are not interested in the build results, but in looking at the compilation time dependencies. For example, if you want you to investigate the build time dependencies of the hello package. Then using the nix-store command as follow, you can request all the dependencies of the build recipe:
$ nix-store --tree -q $(nix-instantiate '