I'm new to Nix and I'm trying to understand the hello derivation given in example.
I can understand the syntax and what is supposed to do, however I don't understand
how the initial arguments (and the especially the perl
one_ are fed ?
I mean, who is setting the perl
argument before calling this derivation.
Does that mean that perl
is a dependency of hello
?
Packages are typically written as set of dependencies -> derivation
functions, to be assembled later. The arguments you ask about are fed from pkgs/top-level/all-packages.nix, which holds the set of all packages in Nixpkgs.
When you find the hello
's line in all-packages.nix, you'll notice it's using callPackage
- it's signature is path to Nix expression -> overrides -> derivation
. callPackage
loads the path, looks at the function it loaded, and for each arguments provides either value from overrides
or, if not given, from the huge set in all-packages.nix.
For a nice description of callPackage
see http://lethalman.blogspot.com/2014/09/nix-pill-13-callpackage-design-pattern.html - it's a less condensed explanation, showing how you could have invented callPackage
yourself :-).