6

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:


The answer actually points to callPackageWith function in customisation.nix, but callPackage itself is defined elsewhere.

toraritte
  • 5,163
  • 3
  • 36
  • 58
  • Just learned that there is also a `callPackages` function (from [Nixpkgs#36354](https://github.com/NixOS/nixpkgs/issues/36354) issue), and basically both are undocumented. – toraritte Oct 28 '19 at 03:52

2 Answers2

10

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.

Robert Hensing
  • 5,663
  • 16
  • 21
1

Before flakes I used nix edit nixpkgs.callPackage and with flakes nix edit nixpkgs\#callPackage.

And it works regardless if it lambda or not. E.g. nix edit nixpkgs\#nix.meta

ony
  • 10,885
  • 1
  • 31
  • 41
  • Never heard of `nix edit`, and just checked out all subcommands with `nix --help`, thanks! It didn't work for `callPackage` however, even though `nix edit nixpkgs.hello` (or any other package) did. (I have version 2.3.10.) – toraritte Apr 18 '21 at 13:34