show-derivation:
$ nix show-derivation /nix/store/kg2g9q5chm6dyn2hh8pk8zxwkgb4ph7q-myname.drv
{
"/nix/store/kg2g9q5chm6dyn2hh8pk8zxwkgb4ph7q-myname.drv": {
"outputs": {
"out": {
"path": "/nix/store/bgzq8iyk93c2cxpcsqapfrwij5kwfnpc-myname"
}
},
"inputSrcs": [],
"inputDrvs": {
....
}
Nix does not build derivations during evaluation of Nix expressions. In fact, that's why we have to do :b drv
in nix repl, or use nix-store -r
in the first place.
An important separation is made in Nix:
-
Instantiate/Evaluation time: the Nix expression is parsed, interpreted and finally returns a derivation set. During evaluation, you can refer to other derivations because Nix will create .drv files and we will know out paths beforehand. This is achieved with nix-instantiate.
-
Realise/Build time: the
.drv
from the derivation set is built, first building.drv
inputs (build dependencies). This is achieved with nix-store -r.
Think of it as of compile time and link time like with C/C++ projects. You first compile all source files to object files. Then link object files in a single executable.
In Nix, first the Nix expression (usually in a .nix
file) is compiled to .drv
, then each .drv
is built and the product is installed in the relative out paths.
$ nix-shell -p '(import <nixpkgs> {}).haskellPackages.ghcWithPackages (pkgs: [ pkgs.lenses pkgs.aeson ])'
shell> ghc-pkg list