Search code examples
nix

Nix: what's the concrete difference between nixpkgs and nixpkgs.pkgs?


In:

n = import <nixpkgs> {};

n contains an attribute n.pkgs, which also seems to contain all the available packages. What's the difference then between n and n.pkgs?

It seems it's related to the fixpoint semantics of Nix configuration and the availability to override some packages from nixpkgs, but I can't really wrap my head around it and find a clear distinction.


Solution

  • import <nixpkgs> {} gives you a pristine instance of Nixpkgs, i.e. without any user-configuration applied.

    (import <nixpkgs> {}).pkgs gives you a version of Nixpkgs that has user-configured settings and overrides from ~/.nixpkgs/config.nix applied.