We do effectively have this already: it’s the Breaking changes announcement for unstable thread which I originally posted to! Although my post there was a reaction to experiencing a breaking change, the intent is that changes are proactively posted there before being merged to give people some time to adjust their configurations.
To me, it seems like one problem was that neither the author nor reviewer of the change saw it as potentially-breaking. (This is backed up by the release notes change going into the “Other Notable Changes” section, not the “Backward Incompatibilities” section.) Unfortunately I don’t know that this can be fixed in the general case: every change breaks somebody’s workflow. Perhaps a link to that thread could be included in the pull request template checklist, though (a checkbox for “posted in the breaking changes thread”, in the same vein as “added a release notes entry”), to encourage people to evaluate it as an option?
A difficulty here is that people are in general not aware of all of the software on their machines. (And I won’t accept that this is a problem that needs to – or can – be fixed.) Equally, not every part of nixpkgs has an active maintainer, and even active maintainers can miss things (for example, the hypothetical maintainer of the i3lock module probably uses that module, so breakage as a result of not using that module is likely to slip by them). In a universe where messaging that “some PAM modules will be conditionally enabled now” had gone out ahead of time, would that have been sufficient to alert anyone of the impending breakage?
On the other hand, messaging like that, of “changes we don’t think will break anything but we’ll broadcast it just in case”, can make it easier to root-cause a problem if one does occur. I was lucky to stumble across the responsible PR while searching for “PAM” in recently-merged PRs; if that failed I would have had to bisect nixpkgs which is far more annoying.
Lastly I think it might be valuable to have a little more documented guidance about what to do in the event of unexpected breaking changes. There were at least a couple of people calling for the breaking part of the PR to be reverted, and the author was happy with that possibility, but (to my knowledge) nobody submitted a PR to do so. Was that the right call? Should we revert the change now, even though it’s been almost two weeks? (Perhaps there is some bystander effect at work here: were people waiting for others to submit a revert? or was the consensus truly that a revert wasn’t needed?)