Hacker News new | past | comments | ask | show | jobs | submit login
Nixpkgs Overlays Are Monoids (haskellforall.com)
14 points by JNRowe on Jan 26, 2022 | hide | past | favorite | 5 comments



nix overlays are one of the killer features of nix[os]

trivial to make a minor tweak or even used a forked repo without changing anything else in the system in regards to installing packages,upgrading or maintaining. Completely transparent

I don't really understand the Monoid part of this post though


Monoid is just a binary associative "mappend" function + an identity "mempty" to that function such that "mappend whatever mempty = whatever"

It's a very common structure across programming domains.

The identity overlay is "self: super: {}"

Overlay combination is associative. If you have N overlays, it doesn't matter the order to apply them left-to-right.

In fact, I believe overlays are also commutative. Which makes sense - it would be silly if you wrote an overlay in isolation and how it worked depended on where it landed in your overlays list.


The order in which you combine overlays can sometimes matter. In other words, overlays are monoids, but not commutative monoids. That said, most of the time overlay order does not matter


Ah that's true thinking about it. If I have two overlays that both set some value to X..one's gotta win!


> In fact, I believe overlays are also commutative.

No. But "nice" overlays probably should have this property, since commutativity means orthogonality.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: