Adding "placeholder" parameter to the attrs type allows changing the name that shows up in the docs. Since we have two in a row, this adds clarity here.
The memoize function is not a pretty thing in terms of implementation,
but it's exactly what we need to solve this UX problem and performance
problem.
Without this, every distinct `withSystem` call will cause a re-evaluation
of the `perSystem` module, which is inefficient. Now, it's a one-time
13KB and length(system) attribute lookups: negligible compared to any
instantiations and such.
Nix doesn't offer memoization for functions yet, so this is the best we
can do.
Initially this had some feature checking with lib.functionArgs, but
I don't think this is useful. The _class attribute is not supported
by long-unsupported Nixpkgs (<23.05) anyway, so let's keep it simple.
The difference is that moduleLocation is "guaranteed" reliable data,
whereas errorLocation is the best choice for error messages in the core.
moduleLocation is suitable for the module key attribute.
errorLocation is best for the *ROOT* module _file attribute.
Initially I applied errorLocation in too many places. It is only needed
when the flake output attribute names are strict in it.
To avoid confusion, I'm not exposing errorLocation to the modules, until
we have a concrete use case for it.
`outPath + "/flake.nix"` is technically an unfounded assumption,
except almost all calls will be made from flake.nix.
It surely is a lot better than `<unknown location>`.