Who is 'self' in flake outputs?

I’m diving into flakes for the first time - trying not to skip any detail.

In Flake format the arguments to the function outputs are { self, nixpkgs }:

Some questions:

  1. Who is self in this context?
  2. Can I inspect this instantiated in the nix-repl?
    2.1 If so can someone show me a simple walk-through?

Cheers…

self is outputs. The following trivial flake might help:

{
  outputs = { self }: {
    a = 1;
    b = self.a + 1;
  };
}

for which nix eval .#b results in 2.

The self reference is useful, for example the packages, modules, and overlays flake outputs can be used in your nixos host configurations which would be in outputs.nixosConfigurations.

4 Likes