This commit is contained in:
Mats Rauhala 2019-03-27 23:00:36 +02:00
parent 4c8df0c5df
commit afcfc7bb07
1 changed files with 7 additions and 0 deletions

View File

@ -66,6 +66,13 @@ You can try those yourself. The first version is fine and returns an attrset
like you would expect. The second one has a cyclic dependency and nix helpfully
errors out.
The next step is making a function that has access to the unmodified original
values. This is managed through the `extends` function. It took a while for me to understand what's happening in there, but luckily nix has [good documentation](https://github.com/NixOS/nixpkgs/blob/67b1265fb3d38ead5a57fee838405a2d997777c2/lib/fixed-points.nix#L37-L65) for it.
``` nix
extends = f: rattrs: self: let super = rattrs self; in super // f self super
```
- https://elvishjerricco.github.io/2017/04/01/nix-style-configs-in-haskell.html
- https://github.com/NixOS/nixpkgs/blob/master/lib/fixed-points.nix
- https://chshersh.github.io/posts/2019-03-25-comonadic-builders