3 ms·
> nix is off - I can't work out what parameters are needed for any one function call they all appear to be in a global namespace. If you are talking about some
by hamandcheese 3y ago
> nix is off - I can't work out what parameters are needed for any one function call they all appear to be in a global namespace.
If you are talking about something you saw in the nixpkgs repo, then that is probably the callPackage design pattern [0], which is basically a form of automatic dependency injection.
It definitely made it hard for me to grok how nixpkgs package definitions worked at first - there was so much stuff getting injected dynamically, without any trace of where those dependencies lived.
The callPackage pattern is an important piece that allows you to override a dependency with a different version, though, which is essential when customizing existing packages for your own needs.
[0]: https://nixos.org/guides/nix-pills/callpackage-design-pattern https://nixos.org/guides/nix-pills/callpackage-design-patter...
- pasc1878 3y agoNo in setting up a flake to configure my system but yes callPackage seems odd as well
- SAI_Peregrinus 3y agoI'd say Nix-the-language isn't that hard or weird. Nixpkgs-the-standard-library is much, much harder, and basically undocumented. Nixpkgs-the-repository is nice and search.nixos.org works well.
- pasc1878 3y agoNix the language is OK if it is all in one file. How files all each other and the parameters is odd. You call a function with two parameters but the file starts with many