`wayland-scanner` appears to be a build dependency of itself

It appears that

  1. The package wayland-scanner is defined within the post-fixup stage of the the wayland build
    (EDIT: Is that accurate? Am I just missing the “REAL” definition of wayland-scanner somewhere else? How are a few lines within the post-fixup stage enough to make a “package”?).
  2. The wayland package lists wayland-scanner in “nativeBuildInputs” and thus seems to depend upon wayland-scanner.

I am surely failing to understand something here.
Please point out my misunderstanding.

wayland-scanner is just an alias for bin output of the wayland package so you pinpointed the correct expression:

https://github.com/NixOS/nixpkgs/blob/1c3a28d84f970e7774af04372ade06399add182e/pkgs/top-level/all-packages.nix#L24769-L24770

However, the program is installed by the project itself (in the default mesonInstallPhase) – the postFixup hook just creates a pkg-config file.

Yes, if wayland-scanner were in nativeBuildInputs, it would cause a dependency cycle. However, the scanner is only added to inputs when cross-compiling so it is not a problem:

For example, pkgsCross.aarch64-multiplatform.wayland depends on wayland-scanner (aka wayland.bin) but the latter is a native package so it does not actually depend on wayland-scanner.

Nixpkgs does some magic to ensure pkgsCross.aarch64-multiplatform.wayland gets wayland-scanner instead of pkgsCross.aarch64-multiplatform.wayland-scanner one might expect, so there is no cycle.

Thank you @jtojnar for an in-depth and clear explanation.

In particular, your link to the nixpkgs/pkgs/top-level/all-packages.nix source and explanation of the alias notion made sense out of this mystery.