Newbie question about all-packages.nix

Hi Nix!
So, I noticed pkgs/top-level/all-packages.nix file in nixpkgs. And after seeing it I have some questions:

  1. Are all packages available to use mentioned in this file?
  2. Why this file exists? Can Nix keep track of all these values without this file?
  1. No, for a at least two reasons: some packages are contained in subsets (eg. pythonPackages.requests), so they won’t be listed directly there, and others are using a new mechanism (pkgs/by-name).

  2. I guess It was (still is?) the simplest way to make a bunch of packages accessible: list everything manually into a big attrset, import it, done. The downside is that you have a huge file and potential for lots of merge conflicts.

Note: Nix doesn’t enforce any specific structure for package sets like Nixpkgs, the notion of package isn’t even a primitive (only “derivations” are, meaning the build recipes) and it doesn’t discover .nix files or anything like that.

If you’re interested about the new way, take a look at RFC 0140.

2 Likes