callPackage
callPackage
is a convenience function in nixpkgs
.
Supposing we put the Nix expression in Hello, Nix!ᛦ in a file at ./hello/default.nix
,
hello = callPackage ./hello { };
is equivalent to
hello = import ./hello {
inherit stdenv fetchurl perl;
}
That is, callPackage
inherits whatever values are in scope for the arguments of the derivation. Values can be overridden in the curly braces. If we had our own special perl
called myPerl
, we could say
hello = callPackage ./hello {
perl = myPerl;
};
or, equivalently,
hello = import ./hello {
inherit stdenv fetchurl;
perl = myPerl;
}