Where is `callPackage` defined in the Nixpkgs repo (or how to find Nix lambda definitions in general)?

牧云@^-^@ 提交于 2019-12-13 16:16:48

问题


Found a lot of sources describing callPackage and some of its internals, but none that refers to it's location. It's like the best kept secret of Nix, and the manuals even seem to be actively avoiding the topic. I could find it given time, but it's a huge repo.

Resources:

  • How does Nix's “callPackage” call functions defined without an ellipsis? (Stackoverlow)
  • Nix Pills, Chapter 13. Callpackage Design Pattern Nix

回答1:


nix repl can tell you the location where a lambda is defined.

$ nix repl
Welcome to Nix version 2.2.2. Type :? for help.

nix-repl> pkgs = import <nixpkgs> {}

nix-repl> pkgs.callPackage
«lambda @ /nix/store/9hffpjaa2a7djl19ncky7zcvlhyj76dn-nixos-19.03.172396.d740b2ee855/nixos/lib/customisation.nix:108:31»

where the part up to and including nixos is my <nixpkgs>, thus giving you the answer: lib/customisation.nix line 108.



来源:https://stackoverflow.com/questions/56121361/where-is-callpackage-defined-in-the-nixpkgs-repo-or-how-to-find-nix-lambda-de

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!