tazjin / nix-1p

A (more or less) one page introduction to Nix, the language.
https://code.tvl.fyi/about/nix/nix-1p
896 stars 24 forks source link

Clarify the description of "callPackage" #23

Open WayneSherman opened 7 months ago

WayneSherman commented 7 months ago

With reference to: https://github.com/tazjin/nix-1p/blob/1cf10d3fb78d2500ea46640492e0a92aeda5fe69/README.md?plain=1#L578-L580

Looking specifically at the phrase "the set in which it is defined" it isn't clear: 1) What is "it"? (the callpackage function?)

2) Which set is being described?

The callpackage function does not appear to be defined as part of a set in this example: https://github.com/tazjin/nix-1p/blob/1cf10d3fb78d2500ea46640492e0a92aeda5fe69/README.md?plain=1#L572-L575

tazjin commented 7 months ago

This is about the set from which you got the callPackage function, so in the case of pkgs.callPackage, "it" is that function itself, and the set is pkgs.

There are callPackage functions in multiple different sets (e.g. inside of pkgs.haskellPackages, pkgs.emacsPackages and so on) which all are capable of calling packages with the stuff defined in the set that they themselves are in.

Gonna think about a way to rephrase that ... ideas welcome!