You misunderstand my point. I’m well aware of the whole “perfect being the enemy of good” dichotomy. This is not a problem of the environment.stateVersion
error not being verbose enough, it’s a consistent behavior across all errors thrown by the NixOS module system. If you hit any non-syntax/nix type error you end up in this situation:
If code consistency is concerned, your PR is tantamount to adding a new policy stating that the hostname should be added manually to every single warning or error thrown by the module system. Whatever edge case you’ve hit here can be hit in many, many ways through other modules.
My issue is that even if we were to add such a policy, it’s not very helpful. This only helps people crossing hostnames within a single eval, and only if they don’t realize they can evaluate a subset of what they were trying to evaluate to figure out where the error is, and only if they have a mental association between that hostname and whatever they did that could cause this really specific error. I’d be mildly surprised if this even helps you with the error you have right now.
I think educating people (including you) on this quirk of the module system is a far more sustainable solution to the problem, assuming that just fixing the module system isn’t possible.
In simpler terms, you’re throwing some duct tape on a single hole at the end of a pipe with a massive burst in it because you think that hole might cause water to drip somewhere. Sure, you can kind of call it “making it better”, but it doesn’t actually help anyone else and neither you nor others will actually learn how to work with the fact that you’re using a burst pipe.
No, sadly that wouldn’t really help. The issue is the module system, i.e. the thing we really call “NixOS”, besides all the modules written on top of it. It does not push enough information down the evaluation pipeline to actually display more sensible errors. Nix can trace the eval path, but this doesn’t help in practice since it’s really not human readable.
The NixOS module system isn’t directly supported by nix, it’s a fully separate piece of quite impressive engineering fully written in nix, the programming language - unfortunately this separation also means that it doesn’t have particularly great performance characteristics, because nix isn’t really intended to be a super speedy programming language.
Many of the issues in NixOS stem from this separation, the issue of module system errors probably being the most impactful one.