Pre-RFC: Decouple services using structured typing

Indeed those are interesting topic but as mentioned by @waffle8946 these are out of scope for the RFC.

About 1. Package Overrides as a Use Case did you know some modules allowed you to override the package? Like this one.

Is that because youā€™re not looking to design a generic interface/implementation mechanism? It just felt like another use case to inform the design if that was the goal. But perhaps you were thinking about something much more specific? To me, your interface idea looks in principle quite generic and not limited to services, and Iā€™d be delighted if the same mechanism could be applied to different domains. But, sure, it also makes sense to focus on a specific use case if thatā€™s what you are looking to solve.

And in any case Iā€™m happy about this proposal, because I think more thought out software engineering methodology is what Nix needs. :slight_smile:

Yes, but we havenā€™t demonstrated this idea for services yet. Of course work can be done in nixpkgs in parallel, but thatā€™s a whole other discussion to be had there. Adding that to this RFC means more to bikeshed about, at least from past observation.

2 Likes

If we can solve more issues even with this RFC, I would be delighted. But I donā€™t see at all how it could be applied to the problems you described. If you have any idea I would be happy to hear it! :slight_smile:

Indeed the goal is to decouple services - modules in nixpkgs - using structural typing.

3 Likes

Ah, now I see what you mean! I wasnā€™t suggesting adding those use cases to this RFC (I agree that wouldnā€™t be a good idea)ā€”just that keeping additional use cases in mind might help refine the abstractions further. By thinking about corner cases from other domains, the resulting interfaces could become even neater and more versatile. To be clear, Iā€™m not looking to hijack this RFC or propose competing ideas.

Fair enough! I think Iā€™ll have to flesh out applying this to the cases I mentioned a bit more. :slight_smile:

Perhaps I can clarify where Iā€™m coming from.

The motivation for my thoughts comes from experiences with Nix the language, nixpkgs, and NixOS. Package overriding felt like an example that I encounter often, but it may have been more misleading than helpful. (I hadnā€™t even thought about NixOS modules, which perhaps underscores that Iā€™m not communicating very clearly. :see_no_evil:) In general, a lot of what feels incoherent to me seems to stem from the lack of tools to encourage structural typing or coherent interfaces. Without these, the path of least resistance often leads to ad hoc solutions.

So my thinking isnā€™t primarily about ā€œmaking package overrides easierā€ but about encouraging some sound software engineering principles and providing tools to support them, primarily structural typing, contracts and the subsequent ability to test components in isolation (Iā€™ve actually framed it more as Haskell style type classes, but I think thereā€™s no big difference). I believe approaches like these will demonstrate their value when applied, and I hope people will over time apply them to other parts of the ecosystem, making everything more maintainable and cohesive.

This is why Iā€™m excited by your RFC from a general perspective; I hope it will have a ripple effect beyond service decoupling.

4 Likes

Iā€™m excited because all the comments so far are really positive. Thank you all for that!

If you see some issues, speak up! If not, Iā€™ll be writing the real RFC soon with an accompanying draft PR.

6 Likes