plan modules: expose `identifier.unit-id` and `package-ids-by-name` (#2503)
* plan modules: expose `identifier.unit-id` and `package-ids-by-name`
Pure additions for consumers that need to look up packages by
plan-id rather than canonical name.
* `package.identifier.unit-id` (modules/package.nix): a new
optional field carrying plan.json's per-entry `id` (defaults to
null when not derived from a plan entry).
* `modules/install-plan/planned.nix`: when constructing the
per-plan-id package entries, populate `package.identifier`
with `name` / `version` / `unit-id`. Without this,
reading `package.identifier.{name,version}` on a plan-id-keyed
entry threw — the canonical-name-keyed entry already gets a
real identifier via `load-cabal-plan.nix`, but the per-plan-id
ones (used when one canonical name has multiple plan instances)
did not.
* `package-ids-by-name` (modules/plan.nix +
install-plan/override-package-by-name.nix): a name → [id]
index over `plan-json.install-plan`. A canonical pkg-name can
appear under several plan ids (per-instance UnitIDs that differ
only in their dep UnitIDs, or a multi-component package split
across per-component entries); consumers can now iterate the
ids unambiguously instead of name-matching against
`config.packages`.
* plan modules: expose `plan-json-by-id`
Index `config.plan-json.install-plan` by its per-entry `id` so
consumers can look up a single plan entry with one attrset
lookup instead of a linear scan over the install-plan list.
The keys are haskell.nix's per-instance UnitIDs; the values are
the corresponding plan-json entries.
Computed once in
`modules/install-plan/override-package-by-name.nix` (alongside
`package-ids-by-name`) and exposed via the new
`config.plan-json-by-id` option on `modules/plan.nix`.